Ru2ja
Ru2ja

Reputation: 1

How to provide user defined argument and value in docker run?

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

Answers (2)

priyaranjan
priyaranjan

Reputation: 129

You can achieve it using environment variable. There are two ways to set environment variable.

Upvotes: 2

Qasim Sarfraz
Qasim Sarfraz

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

Related Questions