Some docker / podman tricks that are easy to forget.

Prune old docker/podman data

docker container prune -f
docker image prune -f
docker volume prune -f
docker network prune -f

# Or just all
docker system prune -af

Copy

  • docker cp <container>:<container-path> <host-path>

Login

  • docker login [Server]
  • login to dockerhub in podman: podman login docker.io
  • GPG credential store (by default it uses plaintext)

Formatting output

https://docs.docker.com/config/formatting/

docker inspect --format "{{lower .Name}}" container
docker ps --format "{{json .Names}}"

# To find out what data can be printed, show all content as json:
docker container ls --format='{{json .}}'

Move docker storage location

Here 🤷‍♂️

Image history (layers)

podman/docker history --no-trunc <imgae>

Save container state as image

We can save changes made to container as an image. The command is podman commit <hash> <image-tag>.

Connect to local ports from container

Just run container with --net=host param.

Podman - with docker-compose

podman-compose is great but it fails sometimes with complex docker-compose files. Fortunately we can use podman with docker-compose. Here is how:

Source

# yay -S podman-docker docker-compose podman-dnsname
sudo systemctl start podman.service
sudo   docker-compose up -d

Podman goodies

  • Podman has --replace, --all and --ignore flags (link)
  • Podman can transfer images without registry (link)