Home Cheatsheet - Docker / Podman
Post
Cancel

Cheatsheet - Docker / Podman

This is series of “cheatsheet” articles, which gather tips, hacks, useful commands for given tool.

Commands

Run docker

1
docker run -it --rm -p 3000:3000 -e "DEFAULT_STEALTH=true" -v '/tmp/pdf:/usr/src/app/workspace' browserless/chrome:latest

-it interactive (runs in foreground)

--rm automatically removes container (when closed Ctrl+C)

-p map host port to container port

-e set environment variable

-v mounts host folder into container folder

Log into container:

1
docker exec -it 0d131117dbac bash

Troubleshooting podman

No docker command

1
 echo "alias docker=podman" > ~/.zshrc && source ~/.zshrc

No “DOCKER_HOST”

1
2
3
4
5
6
7
8
9
systemctl --user start podman.service
ls /run/user/1000/podman/podman.sock
# if not exist either service didn't start or there is different path 
# see: podman info --format ''

export DOCKER_HOST=unix:///run/user/1000/podman/podman.sock

If docker-compose is used, then additionally:
sudo ln -s /run/user/1000/podman/podman.sock /var/run/docker.sock

Credit: https://docs.localstack.cloud/references/podman

Problem with mounting volumes on Fedora (or when SELinux policy is used)

Add :Z at the end.

1
docker run --volume="$PWD:/srv/jekyll:Z"

Credit: https://stackoverflow.com/questions/24288616/permission-denied-on-accessing-host-directory-in-docker/31334443#31334443

This post is licensed under CC BY 4.0 by the author.