Docker run
The `docker run` command is one of the most used commands when we use the docker CLI (Command Line Interface).
What does happen when we use it and which are the most used options? Check the docs!
But if you don't have time, let’ see it in 2 minutes:
1/12
Under the Hood, `docker run` are 2 commands:
docker create+docker start
- a container layer is created on the top of an image
- the container just created is started
It's important to understand this to avoid confusion between docker run, docker start, and docker create
2/12
Docker RUN Common Options:
--name: assign a name
--rm: remove it when it exits
-p: publish ports
-e: set environment variable
-d: run it in the background
--network: connect it to a network
-i: keep stdin open
--mount: set a volume or bind mount
--user: set a user
3/12
Assign a name (--name)
By default, a random name is assigned, but in general is a good idea to assign a custom name to our containers, as we do to our pets!
4/12
Remove the container when exits (--rm)
Useful for disposable containers and examples. When a container is stopped, it’s automatically removed. Handy
5/12