Skip to content

Instantly share code, notes, and snippets.

@Tset-Noitamotua
Last active February 20, 2019 18:19
Show Gist options
  • Save Tset-Noitamotua/755f64c31650d30fe5c82e56d911b613 to your computer and use it in GitHub Desktop.
Save Tset-Noitamotua/755f64c31650d30fe5c82e56d911b613 to your computer and use it in GitHub Desktop.
Docker Notes

My Docker Notes

Just a collection of my personal notes about Docker usage.

Override docker entrypoint

PROBLEM: Sometime u would like to override the entrypoint of a Docker container. For example if u try to run robod0ck by just calling docker run robod0ck/robod0ck u will most likely get the error [ ERROR ] Expected at least 1 argument, got 0. That's because the entrypoint of the container is the Robot Framework command robot which is assuming at least one arg e.g. a .robot file or a folder with test cases or some command line option like --help, --version etc. So no matter what u do, the container will run the robot command. But what if u want to start an interactive shell session in that container or check the version of RF or Pip installed inside the container? Like for example docker run robod0ck/robod0ck bash.

SOLUTION: You have to override the entrypoint!

NOTE: Be aware that arguments/'command line options' have to be put after the container id/image identifier

docker run -it --entrypoint "command-you-want-to-run" <container-id> <command arguments / cli-options>

# examples
# start interactive bash session
docker run -it --entrypoint "/bin/bash" <container-id>

# print the version of bash
# notice how cli-option '--version' comes after the container id
docker run -it --entrypoint "/bin/bash" <container-id> --version

# list installed python packages with pip
# notice how argument 'list' comes after the image name
docker run --entrypoint "pip" robod0ck/robod0ck list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment