After taking my first look at Docker and then playing around with building images, I've now progressed into other proprietary work stuff, so... won't be sharing that on here. I like having a job.
That being said, I'll just make note of any useful commands I come across this week. As much for me as you!
Creation
- Create an image from a Dockerfile:
docker build .
- Create a container from an image (run in bkgd):
docker run -d <image hash>
- Interact with running container:
docker exec -it <container hash> bash
- Create a container and interact with it:
docker run -it <image hash>
Status
- View images:
docker images
- View containers:
docker ps
ordocker container ls
- View all containers (including stopped ones):
docker ps -a
Removal
(Layers of) images are the blueprint for the application you'd like to run, while containers are an instance of an image. You can spin up multiple containers for a given image, and each container is separate.
Containers
- Stop all containers:
docker stop $(docker ps -a -q)
- Remove stopped containers:
docker rm $(docker ps -a -q)
- Kill all containers (even running ones):
docker rm -f $(docker ps -a -q)
Images
- Remove image (unless a container or another image exists that's based off it):
docker rmi $(docker images -q)
- Force removal:
docker rmi -f $(docker images -q)