You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Show all active containers
docker ps
# Show all active and non-active containers
docker ps -a
Download an image (if it hasn't been previously downloaded) and start a container based on it
# Run the latest version
docker run <image name># Specify the version to run
docker run <image name>:<version number># Example
docker run ubuntu:17.04
# Run the docker container in detach mode (prevent the terminal window from locking up while the container is running)
docker run -d <image name># Attach back to a container
docker attach <container id or name>
Download an image for later use
docker pull <image name>
Stop a docker container
docker stop <container id or name>
Remove a stopped container
# Remove a single container
docker rm <container id or name># Remove multiple containers
docker rm <container id or name><container id or name><container id or name># Alternatively, only the first three letters of the container id need to be provided
docker rm 345 a0b 773
List all images that have previously been downloaded from Docker Hub
docker images
Remove a previously downloaded image
docker rmi <image name>
Execute a command in the container
docker exec<container id or name><command># Example (print contents of file)
docker exec 3eed277c1318 cat /etc/hosts
Start a container and open the shell
docker run -it <image name><command># Example
docker run -it ubuntu bash
View the release details of the OS in the container