8

I run tests inside docker image and I need to pass custom arguments all the time.

When I put arguments after image name docker thinks that argument is image name.

docker run  -t -i image-name -s test.py
docker run  -t -i image-name -- -s test.py

Error:

Failed no image test_arena2.py

Docker version 1.11.2, build b9f10c9

1

3 Answers 3

9

You can build your Dockerfile with a combination of ENTRYPOINT and CMD instructions, which will let you run containers with or without arguments, e.g:

FROM ubuntu
ENTRYPOINT ["/bin/echo"]
CMD ["hello"]

That says the entrypoint is the echo command, and the default argument is hello. Run a container with no arguments:

> docker run temp
hello  

Run with arguments and they all get passed to the entrypoint command:

> docker run temp -s stackoverflow
-s stackoverflow
Sign up to request clarification or add additional context in comments.

1 Comment

Can you post your Dockerfile?
0

docker run -i is good to be the begin of your command line then set of arguments for the run command only then at the very last -t image with image name provided

Comments

-2

Image name should always be at the end of docker run command i.e. as last parameter to the command. Are you fine with passing the values as environment variable using below command

docker run -e "ENV_VAR_NAME=VALUE" -it image_name 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.