Docker Commands

Note: When typing any Docker container ID, you don't have to type the whole thing, just the necessary number of characters that will differentiate the container from others.

Start a Container

docker run ansible
docker run mongodb
... # This runs container in the foreground (attached to stdout of container and you will see output)

docker run -d <repo-name>
# this runs container in the background (detached, won't see output)

docker run <image-name>:<version> # ex. docker run redis:4.0 (called a tag)

docker run --name webapp ansible # Name conainer webapp

List Running Containers

docker ps
docker ps -a # Previously exited containers too

Stop Container

Remove Container

List Images

Remove Images

Download an Image (Doesn't run container)

Executing a command on the container

Attach

Interactive Mode

Inspect Containers

Container Logs

Set Environment Variables

Build Image

Publish Image

See Image build history

Clear Device Memory

Last updated

Was this helpful?