Skip to content

Instantly share code, notes, and snippets.

@kaaquist
Last active May 4, 2024 22:37
Show Gist options
  • Star 98 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save kaaquist/dab64aeb52a815b935b11c86202761a3 to your computer and use it in GitHub Desktop.
Save kaaquist/dab64aeb52a815b935b11c86202761a3 to your computer and use it in GitHub Desktop.
Podman with docker-compose on MacOS.

Podman with docker-compose on MacOS.

Podman an alternative to Docker Desktop on MacOS

Getting podman installed and started is super easy.
Just use brew to install it.

> brew install podman

Now since podman uses a VM just like the Docker Client on MacOS we need to initialize that and start it.

> podman machine init
> podman machine start

Now we are set to go.

If you want you can create a symlink so podman can be executed with "docker" command.

> ln -s /usr/local/bin/podman /usr/local/bin/docker

Now most of the commands in podman are the same so try podman images and you will get a list of images.
Else the podman --help command list all the help you need.

To get docker-compose without the docker client for mac. You can install it using the brew command.

> brew install docker-compose

When that is done you now should have the ability to use docker-compose with podman.

On MacOS the podman project does not expose the podman.socket which is similar to docker.socket, by default. So to get docker-compose working one needs to expose the socket.

To get the socket running run the following commands.
First we need to find the port it is exposed on in the VM.

> podman system connection ls

Then we need to take that port and create a forward ssh connection to that.

> ssh -fnNT -L/tmp/podman.sock:/run/user/1000/podman/podman.sock -i ~/.ssh/podman-machine-default ssh://core@localhost:<port to socket> -o StreamLocalBindUnlink=yes
> export DOCKER_HOST='unix:///tmp/podman.sock'

Second, we expose the DOCKER_HOST env variable that is used by docker-compose.

Be aware that if the connection is disconnected one needs to delete/overwrite the /tmp/podman.socket to run the forward command.

Overall findings is that if one only runs single images then it is fairly easy to get going using podman. But if you rely on the compose part to orchestrate the containers in a bigger setup of different images with networking etc. then podman is a lot less easy to get working "out of the box". There is a lot of googling involved and then it still seems that there are a lot of the features that are not too easy to get working. I did have a lot of issues getting the right permissions to mount drives into the images. One of the main features with podman is that it is rootless. Which is great but it means that you need to understand what permissions a container needs before it fully works. I have tried to use the podman-compose as the goto instead of docker-compose, but I had a hard time even getting it installed, and there were alot of issues where it could not load images from the local repository, so in the end that is why I decided to use docker-compose and not podman-compose. Another thing is that podman-compose is also developed by people not really part of the podman community it seems, or it is not set to be the frist choice by the podman community. So it seems that it is a project that has its own agenda, and is run by a few people and not as many as the podman community. For now I got it working but I will say that there are many wheels that need tuning and kept updated to have the setup running in a daily development environment. So if you, like me, just want to use the tools and not need to finetune all the time, it seems a little like there is a way to go before podman takes over the MacOS setup. Next for me is to try to setup everything on my linux laptop and see if this works easier out of the box.

@nitesr
Copy link

nitesr commented Sep 29, 2023

Thank you for sharing. I am getting below error, how do I solve ?

Attaching to dashboards-grafana-1
Error response from daemon: crun: write to `/proc/self/oom_score_adj`: Permission denied: OCI permission denied
Error: executing /usr/local/bin/docker-compose up grafana: exit status 1

I did these steps and trying to run grafana using docker compose

brew install podman
podman machine init # download linux vm
podman machine start #start vm


ln -s /usr/local/bin/podman /usr/local/bin/docker
brew install docker-compose #install docker compose
export podman_sock_port=`podman system connection ls | cut -d ":" -f 3 | cut -d "/" -f 1 | grep "[0-9]" | uniq` #get podman.socket
ssh -fnNT -L/tmp/podman.sock:/run/user/1000/podman/podman.sock -i ~/.ssh/podman-machine-default ssh://core@localhost:${podman_sock_port} -o StreamLocalBindUnlink=yes #expose podman.socket
export DOCKER_HOST='unix:///tmp/podman.sock'
mv ~/.docker/config.json ~/.docker/config.json.old; cat ~/.docker/config.json.old | grep -v "\s*\"credsStore\"*" > ~/.docker/config.json 

@996639938
Copy link

@richtong
about the error Error response from daemon: make cli opts(): making volume mountpoint
use following command may help you:

podman machine init
podman machine set --rootful
podman machine start

@mvmn
Copy link

mvmn commented Jan 31, 2024

I still get the same error (no permissions on mounted volume), setting rootful or adding userns_mode: "keep-id" doesn't help.

@kaaquist
Copy link
Author

kaaquist commented Jan 31, 2024

您的邮件我已经收到啦~我会尽快回复您的! by何劲和

Please keep the conversation in English. Thanks.

@jorge-senger
Copy link

Error response from daemon: make cli opts(): error making volume mountpoint for

This error can be fixed by starting podman machine with the --rootful flag:
podman machine set --rootful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment