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
8,434 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

How do I fix this error? docker run --- name “xyz” is already in use by container

You need to remove container "registry-v1". Run docker rm ...READ MORE

answered Feb 19, 2021 in Docker by Abhinav Kumar

edited Mar 5, 2025 13,865 views
+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
256,688 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
2,101 views
+2 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
7,767 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
3,786 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
1,777 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