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
• 7,020 points
5,693 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,680 points

edited Jul 11, 2018 by Kalgi

Related Questions In Docker

0 votes
1 answer
+2 votes
12 answers

How to run multiple commands in docker at once?

In order to run multiple commands in ...READ MORE

answered Jul 19, 2018 in Docker by Sophie may
• 10,550 points
129,343 views
0 votes
2 answers
0 votes
1 answer
+2 votes
1 answer
+2 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
• 58,120 points
1,142 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,680 points
1,171 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,680 points
227 views