Reputation: 1
I want to achieve something like docker run --delay=
I could provide the value for delay using ENTRYPOINT AND CMD without providing argument in docker run but could not find a way to do from docker run.
In short, I want to know how to pass user defined argument and value to docker run command or using dockerfile
Upvotes: 0
Views: 2261
Reputation: 129
You can achieve it using environment variable. There are two ways to set environment variable.
In Dockerfile -> You can set as follows. Detailed Explanation at https://docs.docker.com/engine/reference/builder/#env
ENV <key> = <value>
In docker run command -> You can set using -e
flag. Detailed Explanation at https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e-env-env-file
docker run -e <key> = <value> <image_name>
Upvotes: 2
Reputation: 6432
There are multiple ways to do that but I would recommend to go with environment variables. Just define the variable while running docker run
and use it in your ENTRYPOINT
script.
docker run -e DELAY=30 IMAGE [COMMAND] [ARG...]
Afterward use it in your ENTRYPOINT
script as:
!#/bin/bash
# Play with $DELAY
echo $DELAY
# Start the root process
exec root_process_command
I hope it help!
Upvotes: 0