Dockerfile entrypoint script arguments in docker run

0 votes

My Dockerfile contains a

RUN xyz.sh --IP localhost

and when I give the command docker run I want to insert a new IP address:

docker run -it IP 127.0.0.1 name:tag

How to pass it like this?

I tried to give ENV in Docker file and using -e in run command but nothing works.

Jul 11, 2018 in Docker by Nilesh
• 6,880 points
1,707 views

1 answer to this question.

0 votes
RUN instructions happen at build time.

ENTRYPOINT and CMD instructions happen at run time.

You probably want something like this in your Dockerfile:

....

ENTRYPOINT ["xyz.sh"]

CMD ["--IP", "127.0.0.1"]

....

Then you can run with:

docker run -it some-image --IP 127.0.0.1

Arguments after the image overwrite the CMD instruction so then it runs the ENTRYPOINT instruction followed by your arguments.
answered Jul 11, 2018 by Kalgi
• 2,620 points

edited Jul 11, 2018 by Kalgi

Related Questions In Docker

0 votes
1 answer
+1 vote
11 answers

How to run multiple commands in docker at once?

Try this: docker run image bash -c "cd ...READ MORE

answered Apr 17 in Docker by anonymous

edited Apr 17 by Kalgi 22,815 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,900 points
217 views
0 votes
1 answer

How to store data in external drive with Docker Postgres:9.3 image?

Apparently, the problem would be in your ...READ MORE

answered Jul 12, 2018 in Docker by Kalgi
• 2,620 points
173 views
0 votes
1 answer

How to deal with persistent storage (e.g. databases) in docker

For Docker 1.9.0 and above, Use volume API docker ...READ MORE

answered Jul 18, 2018 in Docker by Kalgi
• 2,620 points
69 views