在Docker容器开始运行后运行命令

在我的PHP FPM(7.1-fpm)泊坞窗启动后尝试运行sendmailconfig,但是我很难在不妨碍容器的FPM部分的情况下这样做。

FROM php:7.1-fpm
RUN apt-get update && apt-get install
CMD "/usr/local/bin/config.sh" && /bin/bash

我尝试制作一个脚本,该脚本仅执行yes | sendmailconfig,但似乎阻止了图像的默认脚本运行,这导致PHP-FPM从未真正运行。

我希望在映像中完成此操作的原因是因为每次重启容器时都必须运行sendmailconfig命令,这在管理多个Docker堆栈时不切实际。

cntong 回答:在Docker容器开始运行后运行命令

设置入口点以运行复制到其中的文件,该文件中应包含以下内容

/usr/local/bin/config.sh

# If this isn't the correct command for you to start php-fpm look up the correct one for your image
sudo service php7.1-fpm start

# Execute the CMD passed in from the dockerfile
sudo -H bash -c "$@;"
# You'll probably be ok with just `bash -c "$@;"` if you don't have sudo installed
本文链接:https://www.f2er.com/3144590.html

大家都在问