Docker

From Segfault
(Redirected from Podman)
Jump to navigation Jump to search

Docker

Copy files from a running container to the host:

docker cp $(docker ps | awk '/foobar/ {print $1}'):/home/dummy/tests.txt .

The same, but with wildcards:

$ docker exec $(docker ps | awk '/foobar/ {print $1}') sh -c "tar -C /home/dummy -cf - test*txt" | tar -xvf -
test_03.txt

Disk usage:

$ docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          3         2         6.083GB   77.81MB (1%)
Containers      9         1         123.8MB   123.7MB (99%)
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B

Pruning:

for o in builder container image network volume; do echo "### ${o}"; docker ${o} prune; echo; done
docker system prune

List and remove the build cache as well:

docker buildx du
docker buildx prune --all

Note: the above needs the docker/buildx plugin activated,[1] or installed. Depending on the distribution, the plugin may or may not be available. Install with:[2]

LATEST=$(wget -qO- "https://api.github.com/repos/docker/buildx/releases/latest" | jq -r '.name')
wget https://github.com/docker/buildx/releases/download/${LATEST}/buildx-${LATEST}.linux-amd64
chmod a+x buildx-${LATEST}.linux-amd64
mkdir -p ~/.docker/cli-plugins
mv buildx-${LATEST}.linux-amd64 ~/.docker/cli-plugins/docker-buildx

Tear it all down:

docker container stop $(docker container ls --quiet)
docker container rm $(docker container ls --all --quiet)
docker volume rm $(docker volume ls --quiet)

docker-compose

After cleaning too many images[3] the following could happen:

$ docker-compose build --no-cache
[+] Building 1.4s (5/43)
[...]
 => [ 1/40] FROM docker.io/library/ubuntu:22.04
 => ERROR [ 2/40] RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
failed to solve: failed to prepare sha256:cdd7c73923174e45ea648d66996665c288e1b17a0f45efdbeca860f6dafdf731 as tk9yg8weecuns67euqaexw0ew:
stat /var/lib/docker/btrfs/subvolumes/41a90c08fd015a7a2dcb850a18500032e8da9a32b330210ecbdc4da0b2d6bf93: no such file or directory

This means we may have to force pull images here:

docker-compose build --no-cache --pull

Podman

An example on how to install Nextcloud with Podman[4]

TBD

Forwarding ports[5] to the now running Pod:

TBD[6][7][8]

Links

References