Docker
Table of Contents
This is just a command reference because I don't touch docker stuff enough to remember what to do. It represents my understanding which is probably quite poor.
Most of this is as it applies to my Jellyfin and Plex setups. I intend to add more stuff that will run on Yamato as well.
From my view there are four main things: an image, config, volumes, and instances.
- Images are immutable software packs.
- Config either exists as arguments to
docker run
or in adocker-compose.yml
- Volumes exist on the filesystem somewhere and docker tracks that, they end up mounted where you specify in the container's filesystem.
- Instances refer to the running instance as a result of all the above.
Instances seem to get created by telling docker to run one (docker run
), or writing compose files (docker-compose.yml
) and telling docker-compose to run that. They survive reboots, restarts, and stops, but are otherwise ephemeral. Only the remnants they leave behind on volumes are intended to be preserved between their updates, removals, crashes, etc.
Managing containers
Update your image (same as initial pull)
docker pull <namespace>/<image>
Clean up old unused images
docker image prune
Do various things
docker start <container> docker restart <container> docker stop <container> docker rm <container> docker kill <container>
Do various things with docker-compose
If you use a non-standard compose filename don't forget to pass -f compose.yml
.
docker-compose up # build and start docker-compose down # stop and destroy docker-compose build # just build docker-compose start docker-compose restart docker-compose stop docker-compose rm docker-compose kill
Docker volumes
These usually live in /var/lib/docker/volumes
if you want to go play with the files (probably stop the container first).
Create them
docker volume create <volume_name>
List them
docker volume ls
Find where they are
docker inspect <volume_name>
Delete them
docker rm <volume_name>
Playing with live containers
Look at them
Both commands seem to have same output.
docker ps docker container ls
Open a shell inside one
docker exec -it <container> bash
Attach to a container and watch it spit out messages
Credit to https://stackoverflow.com/a/20228669. Don't just attach
, none of the prescribed ways to exit work so you end up killing your container with ctrl+c
. Disable the signal proxy to avoid that.
docker attach --sig-proxy=false <container>
For just seeing the most recent messages:
docker logs <container>