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,060 points
7,530 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
+3 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,620 points
250,212 views
0 votes
2 answers
0 votes
1 answer

Efficient way to run a Docker Compose stack in production?

Here is a concept which you can ...READ MORE

answered Aug 2, 2018 in Docker by Damon Salvatore
• 5,980 points
1,130 views
+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,020 points
2,715 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
2,626 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
771 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP