2020-05-19 09:21:38 +01:00
|
|
|
# docker run
|
|
|
|
|
|
|
|
> Run a command in a new Docker container.
|
|
|
|
> More information: <https://docs.docker.com/engine/reference/commandline/run/>.
|
|
|
|
|
|
|
|
- Run command in a new container from a tagged image:
|
|
|
|
|
|
|
|
`docker run {{image:tag}} {{command}}`
|
|
|
|
|
|
|
|
- Run command in a new container in background and display its ID:
|
|
|
|
|
2022-07-28 14:03:27 +01:00
|
|
|
`docker run --detach {{image}} {{command}}`
|
2020-05-19 09:21:38 +01:00
|
|
|
|
|
|
|
- Run command in a one-off container in interactive mode and pseudo-TTY:
|
|
|
|
|
2022-07-28 14:03:27 +01:00
|
|
|
`docker run --rm --interactive --tty {{image}} {{command}}`
|
2020-05-19 09:21:38 +01:00
|
|
|
|
|
|
|
- Run command in a new container with passed environment variables:
|
|
|
|
|
2022-07-28 14:03:27 +01:00
|
|
|
`docker run --env '{{variable}}={{value}}' --env {{variable}} {{image}} {{command}}`
|
2020-05-19 09:21:38 +01:00
|
|
|
|
|
|
|
- Run command in a new container with bind mounted volumes:
|
|
|
|
|
2022-07-28 14:03:27 +01:00
|
|
|
`docker run --volume {{/path/to/host_path}}:{{/path/to/container_path}} {{image}} {{command}}`
|
2020-05-19 09:21:38 +01:00
|
|
|
|
|
|
|
- Run command in a new container with published ports:
|
|
|
|
|
2022-07-28 14:03:27 +01:00
|
|
|
`docker run --publish {{host_port}}:{{container_port}} {{image}} {{command}}`
|
2021-11-06 20:18:08 +00:00
|
|
|
|
|
|
|
- Run command in a new container overwriting the entrypoint of the image:
|
|
|
|
|
|
|
|
`docker run --entrypoint {{command}} {{image}}`
|
|
|
|
|
|
|
|
- Run command in a new container connecting it to a network:
|
|
|
|
|
|
|
|
`docker run --network {{network}} {{image}}`
|