manoj manoj - 1 year ago 166
Linux Question

Dockerfile entrypoint script arguments in docker run

My Dockerfile contains a

RUN --IP localhost

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

docker run -it IP 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.

Answer Source

RUN instructions happen at build time.

ENTRYPOINT and CMD instructions happen at run time.

You probably want something like this in your Dockerfile:


CMD ["--IP", ""]

Then you can run with:

docker run -it some-image --IP

Arguments after the image overwrite the CMD instruction so then it runs the ENTRYPOINT instruction followed by your arguments.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download