简体   繁体   中英

Docker ENTRYPOINT using docker run command

I am running below command to set entrypoint through command line to start nginx service with this container

root@server:~# docker run -it --entrypoint="/bin/bash /root/service.sh" docker-reg.sogeti-aws.nl:5000/ubuntu:v3 bash

root@server:~# cat /root/service.sh

!/bin/bash

service nginx start while true; do sleep 1d; done

so is it possible with docker run command or i need to define Dockerfile only

You can add the ENTRYPOINT instruction at the end of your Dockerfile.

ENTRYPOINT ["/bin/bash","/root/service.sh"]

Of course, you'll need to add the service.sh to your image. Again using a Dockerfile

COPY service.sh /root/service.sh

In the end it will be something like this.

FROM docker-reg.sogeti-aws.nl:5000/ubuntu:v3

COPY service.sh /root/service.sh
ENTRYPOINT ["/bin/bash","/root/service.sh"]

To change the entry point to bash use the following command:

sudo docker run --entrypoint "/usr/bin/bash" -it <any-other-options> <img>

Note: don't add bash at the end, as we use to do when using -it .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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