It's time to replace Docker Desktop with Podman on macOS.
Why doing this change?
I don't need a GUI for running a simple container and I won't continue to use soemthing that needs root permission during it's install/upgrade process.
Also with the big change: Docker Desktop no longer free for large companies: New 'Business' subscription is here
In addition, I use podman to run containers on my workstation, servers and orchestrator (Nomad) so it's more logic to uniformize the stack.
Install
The easy way is using Homebrew
brew install podman
Now, we need to setup the machine
In my case, I've to customize it:
- cpu: 2 cores (default: 1)
- memory: 4 GB (1024 * 4) (default: 2 GB = 2048)
- Disk: 50 GB (default: 10 GB)
podman machine init --cpus 2 --memory 4096 --disk-size 50
Default values are sufficient if you're not doing hard work.
I haven't added a custom name so it'll use the default podman-machine-default
How to start and stop
I use aliases in my ~/.zshrc
alias docker="podman"
alias podmanstart="podman machine start podman-machine-default"
alias podmanstop="podman machine stop podman-machine-default"
`
Quick fix
Do I need it?
After starting using podmanstart
, we'll try to use port forwarding:
podman pull docker.io/library/nginx
podman run --rm -d --name nginx -p 8888:80 nginx
curl 127.0.0.1:8888
If curl fails with this meesage
curl: (7) Failed to connect to 127.0.0.1 port 8888 after 6 ms: Connection refused
You need to apply the fix after doing this clean stop
podman stop nginx
podman rmi nginx
podmanstop
Fix
The fix for port forwarding is adding this lien in ~/.config/containers/containers.conf
rootless_networking = "cni"
All done, you can work correctly and you can replace docker-compose with podman-compose