本文主要介绍了在supervisor下Dockerfile的多业务图像封装 *** 作,具有很好的参考价值。希望对你有帮助。来和边肖一起看看吧。
写入Dockerfile文件
配置yum源
cd/tmp/docker vimDockerfile FROMrhel7 EXPOSE8022#向外暴露80和22的端口 COPYdvd.repo/etc/yum.repos.d/dvd.repo &&yuminstall-yhttpdopenssh-serveropenssh-clientssupervisor &&yumcleanall &&ssh-keygen-q-trsa-f/etc/ssh/ssh_host_rsa_key-N"" &&ssh-keygen-q-tecdsa-f/etc/ssh/ssh_host_ed25519_key-N"" &&echoroot:redhat|chpasswd COPYsupervisord.conf/etc/supervisord.conf CMD["/usr/bin/supervisord"] vimsupervisord.conf [supervisord] nodaemon=true [program:sshd] command=/usr/sbin/sshd-D [program:httpd] command=/usr/sbin/httpd dockerbuild-trhel7:v3 SendingbuildcontexttoDockerdaemon8.192kB Step1/6:FROMrhel7 --->0a3eb3fde7fd Step2/6:EXPOSE8022 --->Runningin5727c9e984a5 --->e25a8a0821f7 Removingintermediatecontainer5727c9e984a5 Step3/6:COPYdvd.repo/etc/yum.repos.d/dvd.repo --->2d9e8f9648a7 Removingintermediatecontainer62955f7a7a74 Step4/6:RUNrpmdb--rebuilddb&&yuminstall-yhttpdopenssh-serveropenssh-clientssupervisor&&yumcleanall&&ssh-keygen-q-trsa-f/etc/ssh/ssh_host_rsa_key-N""&&ssh-keygen-q-tecdsa-f/etc/ssh/ssh_host_ecdsa_key-N""&&ssh-keygen-q-tecdsa-f/etc/ssh/ssh_host_ed25519_key-N""&&echoroot:redhat|chpasswd DependencyUpdated: elfutils-libelf.x86_640:0.166-2.el7 Complete! Skippingunreadablerepository'///etc/yum.repos.d/rhel7.repo' Cleaningrepos:dockerdvd-rhel Cleaningupeverything --->1cb2f9e34bac Removingintermediatecontainer33cb452dbc8d Step5/6:COPYsupervisord.conf/etc/supervisord.conf --->e8de2ff5ca3c Removingintermediatecontainerf219cb2b6a88 Step6/6:CMD/usr/bin/supervisord --->Runningineddfb3973ad2 --->dbf4cf5cb116 Removingintermediatecontainereddfb3973ad2 Successfullybuiltdbf4cf5cb116dockerrun-d-namevm1-v/tmp/docker/web/:/var/www/htmlrhel7:v3
dockerps
dockerinspectvm1 "Networks":{ "bridge":{ "IPAMConfig":null, "Links":null, "Aliases":null, "NetworkID":"126902125dd9c54631622845c1a75d656b45023840c57944ec24f4acecf6dc3f", "EndpointID":"3d995f01fce91968f59b151a19ba3868292efe0a61c2ef355bcd1eb84bda7248", "Gateway":"172.17.0.1", "IPAddress":"172.17.0.2",#容器的ip "IPPrefixLen":16, "IPv6Gateway":"", "GlobalIPv6Address":"", "GlobalIPv6PrefixLen":0, "MacAddress":"02:42:ac:11:00:02" } }验证:
卷曲度
认证sshd服务:
补充知识:使用Dockerfile构建supervisor容器部署项目,cmd["supervisord"、"-c"、"/etc/supervisord.conf"]执行失败
问题描述:
编写Dockerfile创建supervisor容器时,最后一个启动supervisor的命令不起作用-->:Cmd["supervisord","-c","/etc/supervisord.conf"],但是在容器内部执行supervisord-c/etc/supervisord.conf可以成功运行。
首先发布Dockerfile文件代码
FROMpython:latest WORKDIR/root/ RUNmkdir/etc/supervisor RUNmkdir-p/root/projects/logs/gunicorn/ RUNmkdir-p/root/projects/logs/celery/ RUNmkdir-p/root/projects/Sy_EvaluateJkApi/logs/ RUNecho"debhttp://mirrors.aliyun.com/debian/bustermainnon-freecontrib">/etc/apt/sources.list RUNecho"deb-srchttp://mirrors.aliyun.com/debian/bustermainnon-freecontrib">>/etc/apt/sources.list RUNecho"debhttp://mirrors.aliyun.com/debian-securitybuster/updatesmain">>/etc/apt/sources.list RUNecho"deb-srchttp://mirrors.aliyun.com/debian-securitybuster/updatesmain">>/etc/apt/sources.list RUNecho"debhttp://mirrors.aliyun.com/debian/buster-updatesmainnon-freecontrib">>/etc/apt/sources.list RUNecho"deb-srchttp://mirrors.aliyun.com/debian/buster-updatesmainnon-freecontrib">>/etc/apt/sources.list RUNecho"debhttp://mirrors.aliyun.com/debian/buster-backportsmainnon-freecontrib">>/etc/apt/sources.list RUNecho"deb-srchttp://mirrors.aliyun.com/debian/buster-backportsmainnon-freecontrib">>/etc/apt/sources.list RUNapt-getupdate-y RUNapt-getinstall-ygitlrzszvim RUNpipinstallsupervisor-ihttps://mirrors.aliyun.com/pypi/simple/ RUNpipinstallgunicorn-ihttps://mirrors.aliyun.com/pypi/simple/ RUNpipinstallgevent-ihttps://mirrors.aliyun.com/pypi/simple/ RUN/usr/local/bin/echo_supervisord_conf>/etc/supervisord.conf RUNecho"[include]">>/etc/supervisord.conf RUNecho"files=/etc/supervisor/*.ini">>/etc/supervisord.conf ADDsy.ini/etc/supervisor/sy.ini ADDSy_EvaluateJkApi/root/projects/Sy_EvaluateJkApi RUNpip3install-r/root/projects/Sy_EvaluateJkApi/requirements.txt-ihttps://mirrors.aliyun.com/pypi/simple/ EXPOSE8800 CMD["supervisord","-c","/etc/supervisord.conf"]使用dockerbuild-tsystem:test时没有异常。命令构建容器映像,但是用dockerbuild-itdsystem:test运行容器将显示容器没有运行。
解决方案:
将cmd["supervisord"、"-c"、"/etc/supervisord.conf"]命令更改为cmd["supervisord"、"-n"、"-c"、"/etc/supervisord.conf"],它将成功运行。
它被写在supervisor-n/-nodaemon-run中的前台(与配置文件中的'nodaemon=true'相同),添加-n是为了保持supervisor在前台运行。
以上主管下Dockerfile的多业务镜像封装 *** 作,都是边肖分享的内容。希望能给你一个参考,多多支持我们。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)