That being said, I'll just make note of any useful commands I come across this week. As much for me as you!
- 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>
exec command is great. It allows you execute a command inside a running, such as using some tool only available in the container to export some settings, which you can dump in a directory that's being shared with the
-v flag, so that you can import it into future containers. Handy stuff.
- View images:
- View containers:
docker container ls
- View all containers (including stopped ones):
docker ps -a
(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.
- 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)
- 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)