Docker 101

Docker is a tool making use of the cgroups feature of linux kernel to manage containers on top of the host Linux kernel. This article will cover the basic operation commands.

Installation and configuration

I use ubuntu 22.04:

apt install

Limit log file size to avoid storage drain:

	"log-driver": "json-file",
	"log-opts": {"max-size": "10m", "max-file": "3"}

Restart docker daemon:

systemctl restart docker

Make sure your user is a group member of docker

$ grep docker /etc/group

Image Management

# list container images
docker images
# pull container image from a registry
docker pull [image]
# remove docker image
docker rmi [image]

Container Management

# run a container with interactive shell
docker run -it [image]
# start a container and run a command
docker run [image] [command]
# list running containers
docker ps
# list all containers, including all stopped containers
docker ps -a
# stop a running container
docker stop [container]
# remove containers, both name and cointainer id are accepted
docker rm [container(s)]

There are many options for the docker command. For easier management I would suggest to use docker compose, which allows us to use a YAML file to define the containers we need.