Reputation:
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.
Upvotes: 3
Views: 3757
Reputation: 18946
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.
Upvotes: 5