Rohan Khanolkar
Rohan Khanolkar

Reputation: 85

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.bu-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

Upvotes: 2

Views: 3611

Answers (2)

alshaboti
alshaboti

Reputation: 683

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.

Upvotes: 0

Wassim Dhif
Wassim Dhif

Reputation: 1388

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"]

Upvotes: 2

Related Questions