Faster podman (docker) on macOS using a remote linux host

on Christopher Hoelter's Blog

How to run a podman server on native linux while interfacing through a macOS client.
#programming #docker #podman #linux #macos

If you're developing on macOS or windows and you find podman too slow, you can host it on a native linux box and interface with it remotely through your client machine. These instructions are for podman, but the same thing can be achieved for docker.

This guide will cover how to do this using ssh as a connection between your macOS client and the remote linux podman host.

# Setup Linux Host

Install podman (on debian machine)

Enable the podman daemon to listen to remote requests. Sudo should not be needed for this since it's enabled for the user.

Keep the socket alive so that the podman service works when logged out.

# Setup macOS Client

  1. Install podman brew install podman
  2. If you do not have an ssh key setup to access the linux host where podman was installed above, you will need that (See resource 1 at the bottom).
  3. Add the linux host as a podman client connection.
podman system connection add my-new-connection --identity ~/.ssh/id_ed25519 ssh://<server-user>@<server-ip>/run/user/1000/podman/podman.sock

The "my-new-connection" can be any name you want. 4) Check the connection

podman system connection list
podman --remote info

If that's your only connection, that's it! Podman cli commands will now communicate with the linux host to execute container commands. This connection can be set as the default if there are multiple connections: podman system connection default my-new-connection

# Getting docker-compose working with podman remote

  1. Install docker-compose on the macOS client brew install docker-compse
  2. Ensure the DOCKER_HOST env variable is pointing at the remote server ssh connection export DOCKER_HOST=ssh://<server-user>@<server-ip> You may note that the exact socket reference can't be appended to the DOCKER_HOST url, so we need to make a couple changes on the remote host for docker-compose to work. The docker.sock path and docker command are both used by default when docker-compose executes. We can get around that by making a couple symlinks.
  3. Now, on the linux host run sudo ln -s /run/user/1000/podman/podman.sock /var/run/docker.sock to symlink the podman.sock to where the docker.sock would be.
  4. Then run sudo ln -s /usr/bin/podman /usr/bin/docker to create a symlink so that the docker command executes the podman binary.

At this point, docker-compose commands should function as expected using the remote podman host.

# Resources

Here are some resources ordered by most helpful.

  1. https://www.cloudassembler.com/post/remote-podman-service/
  2. https://github.com/containers/podman/issues/11397#issuecomment-910630550
  3. https://docs.oracle.com/en/learn/oracle-linux-platform-images/#create-a-system-connection-to-the-podman-server
  4. https://www.redhat.com/sysadmin/podman-clients-macos-windows

Please leave a comment or drop a message at https://lists.sr.ht/~hoelter/public-inbox. Email me directly at blog@christopherhoelter.com.