Images - Stopped containers Containers - running containers
docker version
- client (local machine)
- server (docker)
docker info
- additional info (more than version)
- system info, number of containers, status of containers, etc.
docker ps
- list currently running containers
docker ps -a
- see recently run containers, but are now done
docker run <name of image>
- run image (checks local first, then checks docker hub if not found local)
docker images
- all images on local machine
docker pull <name>:<version>
- pulls docker image off of docker hub (version optional)
docker rmi <name>:<tag>
- remove image
- you can get the name and tag from 'docker images' command
docker run -d --name web <image name to use>
docker stop <name>
- stops a container from running
docker start<name>
- restart container
docker run -it --name <name> ubuntu:lastest /bin/bash
- -it don't run in background, open in this terminal
docker build <context>
- builds and image from a Dockerfile and a context
- context can be a directory (possibly somethings else?)
- -f flag to point to a directory in the file system containing the dockerfile
- -t to save the built image (specifies the directory to save it to)
- can specify multiple locations to copy it to
docker rmi $(docker images -f “dangling=true” -q)
- Remove all
<none>
images
- Remove all
docker container prune
- Remove all exited containers
- must start with a FROM instruction
- specifies the base image