jaya rohith
jaya rohith

Reputation: 311

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.

my Dockerfile:

FROM centos/systemd

#RUN yum -y install dos2unix


CMD ["usr/sbin/init"]   //here i also want to launch a shell script file

Upvotes: 2

Views: 3441

Answers (1)

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

Build docker: docker build -t DockerImageName:1.0 .

Run docker: docker run --name DockerName DockerImageName:1.0

Upvotes: 1

Related Questions