This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
Docker is a utility to pack, ship and run any application as a lightweight container.
Table of contents¶
Containers that produce kernel panics will induce kernel panics into the host operating system.
A correct kernel config is needed: See: https://wiki.gentoo.org/wiki/Docker#Kernel
After configuring the kernel don't forget to do a kernel make and rebuild!
Then, add it to your init system and start it:
Depending on your
runit implementation, either run:
Finally, check with
# docker info that everything is fine.
TODO : proxy...
Allow docker to be run withouthttps://docs.docker.com/engine/security/#docker-daemon-attack-surface⚠️
Active experimental features of docker, by creating the file
/etc/docker/daemon.jsonwith the following content:
Change Docker root directory
/var/lib/dockerto another location (e.g.
Most distros using Runit won't store active services in the same directory. So let's
$ACTIVE_RUNIT_SERVICE_DIR environment variable holding the path to that
directory. Most common paths are:
/var/service/(e.g. for Void Linux)
/run/runit/service/(e.g. for Artix Linux)
$ sudo systemctl stop docker.service $ sudo systemctl stop docker.socket $ sudo vi /lib/systemd/system/docker.service > ... ~ > ExecStart=/usr/bin/dockerd --data-root="/new/path/docker" -H fd:// > ... $ sudo mkdir -p /new/path/docker $ sudo rsync -aqxP /var/lib/docker/ /new/path/docker $ sudo systemctl daemon-reload $ sudo systemctl start dockerd $ ps aux | grep dockerd | grep -v grep
- It is possible to use a Btrfs or ZFS (or etc) storage driver for Docker, see https://wiki.archlinux.org/title/Docker#Storage_driver and https://wiki.gentoo.org/wiki/Docker#Storage_driver.
Start a container with an interactive Bash shell:
Start a container with an interactive Bash shell, with a pseudo-tty and auto-remove the container when done executing:
--interactivesays you want an interactive session.
--ttyallocates a pseudo-tty.
--rmtells Docker to go ahead and remove the container when it’s done executing.
"shell" into a running container (
Inspect a running container:
Get the process ID for a container:
List the current mounted volumes for a container (and pretty print):
Copy files/folders between a container and your host:
List currently running containers:
List all containers:
Pull down an image (e.g. the latest Rocky Linux image):
List all images:
Remove a docker container:
Remove a docker image (⚠️ check if a container is associated to it beforehand with
$ docker ps -a):
Display system-wide information:
Remove unused data:
Show docker disk usage:
Remove all stopped containers, dangling images, and unused networks:
--all) option to the command.
pair interfaces: operation not supported¶
If you get an error like this one:
docker: Error response from daemon: failed to create endpoint cranky_einstein on network bridge: failed to add the host (vethf55744a) <=> sandbox (vethfce3f4d) pair interfaces: operation not supported.
Maybe you just did a Linux Kernel update, in that case: just restart the computer
/lib/rc/sh/openrc-run.sh: 258: ulimit: too many arguments¶
Using OpenRC, with
/bin/sh as a symlink to
/bin/dash, a warning is issued every time Docker is
started or stopped:
/lib/rc/sh/openrc-run.sh: 258: ulimit: too many arguments * docker: unable to apply RC_ULIMIT settings * Stopping docker ...
If this cheat sheet has been useful to you, then please consider leaving a star here.