2

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

4
  • What is your question ? Commented Sep 14, 2017 at 12:05
  • Entrypoint script must placed inside continer. Commented Sep 14, 2017 at 12:10
  • my question is i want to run nginx service through docker run command so above scenario is possible or not Commented Sep 14, 2017 at 12:11
  • @ Bukharov Sergey : can you give me syntax for above scenario Commented Sep 14, 2017 at 12:12

2 Answers 2

2

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"]
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks but will do same thing with docker run command instead of Dockerfile if yes then how
Thanks now i understand the logic
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.