Passing Different Arguments When Running Docker Image Multiple Times

时间秒杀一切 提交于 2019-12-05 18:57:43

Simply inject your parameter as an ENV.

Declare an ENV in your Dockerfile.

ENV suffix 0
./maker oneapp > /artifacts/oneapp_${suffix}.log

The environment variables set using ENV will persist when a container is run from the resulting image.
You can view the values using docker inspect, and change them using docker run --env <key>=<value>.

That way, you can declare that ENV on docker run, and benefit from its value in the running container.

the operator can set any environment variable in the container by using one or more -e flags, even overriding those mentioned above, or already defined by the developer with a Dockerfile ENV:

In your case, for instance:

docker run -e suffix=2 <image_name>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!