Skip to content

Instantly share code, notes, and snippets.

@weblogix
Last active June 30, 2018 14:36
Show Gist options
  • Select an option

  • Save weblogix/697021a93fc38d02f13a29cd5c6cfa23 to your computer and use it in GitHub Desktop.

Select an option

Save weblogix/697021a93fc38d02f13a29cd5c6cfa23 to your computer and use it in GitHub Desktop.
[Docker cheetsheat] List of common docker commands #docker #cheatsheet

Docker is slow to resolve network

Add to /etc/hosts

127.0.0.1 localunixsocket.local

Volumes

Remove all volumes

$ docker volume rm $(docker volume ls -f dangling=true -q)

Starting and stopping

  • docker start starts a container so it is running.
  • docker stop stops a running container.
  • docker restart stops and starts a container.
  • docker pause pauses a running container, "freezing" it in place.
  • docker unpause will unpause a running container.
  • docker wait blocks until running container stops.
  • docker kill sends a SIGKILL to a running container.
  • docker attach will connect to a running container.

Containers

List

docker containers -a

Stop all

docker stop $(docker ps -a -q)

Remove all

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

Images

List (including dangling)

docker images -f dangling=true		

Delete all

docker rmi $(docker images -a -q)

Delete images

docker rmi $(docker images --filter "dangling=true" -q --no-trunc) 

Update all docker images

docker images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 docker pull 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment