简体   繁体   English

使用centos / systemd作为基本映像时,如何在docker文件CMD中启动init文件和shell脚本文件?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM