Skip to content

Instantly share code, notes, and snippets.

@cipherself
Last active August 29, 2015 14:05
Show Gist options
  • Save cipherself/42c26e57e433443d17c6 to your computer and use it in GitHub Desktop.
Save cipherself/42c26e57e433443d17c6 to your computer and use it in GitHub Desktop.

Docker

Build image from dockerfile

docker build PATH

List images

docker images

List running containers

docker ps

List all containers

docker ps -a

Remove an image

docker rmi IMAGE

Remove a container

docker rm CONTAINER

Stop all containers

docker stop $(docker ps -a -q)

Remove all containers

docker rm $(docker ps -a -q)

Attach to a container, sig-proxy to avoid wrong CTRL+C behavior

docker attach --sig-proxy=false CONTAINER

Detach from a container (leaving it running)

CTRL+C

Detach from a container getting a stacktrace

CTRL+\

Stop a container

docker stop

Kill a container

docker kill

Commit an image from a container

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Copy files/folders from a container's filesystem to the host path

docker cp CONTAINER:PATH HOSTPATH

Diff a container

docker diff CONTAINER

Get realtime events from the docker server

sudo docker events

Show the history of an image

docker history IMAGE

Inspect an image or container

docker inspect CONTAINER | IMAGE

Fetch the logs of a container

docker logs CONTAINER

Restart a running container

docker restart CONTAINER

Search docker hub for images

docker search TERM

Display running processes of a container

docker top CONTAINER

Add tag to an existing image

docker tag IMAGE USER/REPO:TAG

Show corresponding public-facing port of a private port

docker port CONTAINER PRIVATE_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment