Docker Commands.

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application


On windows Pro, Hyper-V needs to be enabled. Then it’s just the matter of downloading and running the installer. You can also use Windows Subsystem for Linux. Docker cannot be installed on Windows Home.

Installation on linux is more straight forward.

Just run this command:

$ curl -sSL | sh

Bacic commands

Running a Container

docker run <image> [command]

This is equivalanet to:

docker create <image>
docker start -a [command] [docker attach]

-a in the start command is to watch for output/attach


$ docker run redis

Display containers on machine

All running containers at the moment:

$ docker ps

And to get a list of containers ever created:

$ docker ps --all
$ docker ps -a

Remove every container

$ docker system prune

Getting Information about Containers

See all the output of a container:

docker log

start command can do the same thing, but it can be expensive and time consuming.

Stopping Containers To give a container a 10 second time to shutdown properly use:

docker stop

To stop is immediately:

docker kill

Execute additional commands in container

docker exec -it <container-id> <command>

-i is used for stdin and to make the container interactive. -t is to make the output prettier and allocate a pseudo-TTY.

A same pattern can be used with run:

docker run -it <image> <command>

© 2019. All rights reserved.