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
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-composeis great but it fails sometimes with complexdocker-composefiles. Fortunately we can usepodmanwithdocker-compose. Here is how:
# yay -S podman-docker docker-compose podman-dnsname
sudo systemctl start podman.service
sudo docker-compose up -d
Comments