Podman allows you to run docker containers (and other OCI formats) on a Mac (or Linux) and can be used to replace Docker Desktop, that in the last year or so became very annoying, demanding constant upgrades and popping up alerts all the time. Podman is a command line tool and it can do pretty much everything Docker Desktop can, without the GUI.
Installation
I’m using the Nix Package Manager what makes the process very convenient – if you are using another tool, please check the steps here. With Nix, just enter:
nix-env -i qemu gvproxy xz podman
I also create a alias to make it shorter to execute (make sure to make it permanent, add this line to your ~/.zshrc or similar) :
alias pod='podman'
Before we continue, check what version you have installed with the command:
pod --version
If version is <= 3.3.1, you need to add :
rootless_networking = "cni"
under the [containers] section of ~/.config/containers/containers.conf – that will guarantee that the network will be available.
Setup the virtual Machine
MacOs can’t run containers natively – We need a virtual machine running Linux that will actually run the containers. Podman uses Qemu under the hood to run this virtual machine and to set it up is quite easy; just run:
pod machine init
That will download and setup an image of Fedora CoreOS for you.
Start the virtual Machine
To start the CoreOS machine, run:
pod machine start
See check information about the virtual machine, run:
pod info
You can also connect via SSH to the virtual machine and check out what’s happening inside:
pod machine ssh
Start the containers
Podman allows you to run containers from a variety of sources so if you wanna use images from the official Docker Repository, you will need to inform the full URL of the image. So to pull the latest version of LocalStack, for example, you will need to run:
pod pull docker.io/localstack/localstack:latest
You can then start the image, just like you would with Docker itself:
pod run -dt -p 4566:4566/tcp -e SERVICES=s3,sqs,ssm -e DEFAULT_REGION=ap-southeast-2 localstack/localstack:latest
For a simpler example, let’s start a HTTPD server:
pod run -dt -p 8080:80/tcp docker.io/library/httpd
A few other command that can be useful (change $INSTANCE by your running container):
pod exec -it $INSTANCE /bin/bash
pod logs $INSTANCEpod inspect $INSTANCE
pod top $INSTANCE
pod port $INSTANCE
How about the Docker Compose
There is a Python 3 package that simulate the docker-compose command pretty well. To install it, run:
pip3 install podman-compose
Now create an alias (if you want):
alias docker-compose='podman-compose'
And start your setup:
docker-compose up
But I need a visual interface
In that case you can give this tool a try:
https://github.com/heyvito/podman-macos
Using your containers with VsCode
I haven’t tried it yet but I’ve found this :
The podman socket is a planned thing for macOS as it will be necessary for certain features that rely on the docker socket and don’t use SSH, such as VSCode’s Remote Containers extension.
However you can create an SSH tunnel to create the socket locally to allow non-podman clients to utilize the socket over SSH with the DOCKER_HOST environment variable.
# Get URI
> podman system connection ls
# Create tunnel
> ssh -nNT -L/tmp/podman.sock:/run/user/1000/podman/podman.sock -i ~/.ssh/podman-machine-default ssh://core@localhost:[PORT]
# Export socket location
> export DOCKER_HOST=’unix:///tmp/podman.sock’