[英]How to launch a init file and shell script file in docker file CMD when using centos/systemd as base image?
My base image is centos/systemd.so
my cmd will contain /usr/sbin/init
but i also want to run a shell script file when the container gets created. 我的基本映像是
centos/systemd.so
我的cmd将包含/usr/sbin/init
但我也想在创建容器时运行shell脚本文件。
my Dockerfile: 我的Dockerfile:
FROM centos/systemd
#RUN yum -y install dos2unix
CMD ["usr/sbin/init"] //here i also want to launch a shell script file
Edit with the solution: 使用解决方案编辑:
FROM centos/systemd
ADD /path-to-hello/hello.sh ./
ENTRYPOINT ["./hello.sh"]
The last line in hola.sh
is exec /usr/sbin/init
hola.sh
的最后一行是exec /usr/sbin/init
Build docker: docker build -t DockerImageName:1.0 .
构建
docker build -t DockerImageName:1.0 .
Run docker: docker run --name DockerName DockerImageName:1.0
运行
docker run --name DockerName DockerImageName:1.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.