Switching to use Podman instead of Docker for spinning up Testcontainers on MacOS just takes a bit of install and configuring. The main reason for the changes is the assumption that Testcontainers makes about the general availability of a Docker socket. Podman is daemonless.
This assumes you are using homebrew to manage packages on MacOS.
Edit ~/.testcontainers.properties
and add the following line:
ryuk.container.privileged=true
Then run the following:
brew install podman
sudo /usr/local/bin/podman-mac-helper install
podman machine init -v $HOME:$HOME
podman machine set --rootful
podman machine set --cpus 2
podman machine set --memory 4096
podman machine start
podman machine ssh
Once you are sshed into the podman machine, run the following commands:
sudo -i
rpm-ostree install qemu-user-static
systemctl reboot
NOTE: The systemctl reboot does restart the podman machine however, this restart doesn’t mount the $HOME directory. You must manually recycle the VM using podman machine stop
and podman machine start
. I’d like those two hours back.
After the VM restarts, update your shell profile of choice to add the alias.
alias docker=podman
Reference: https://github.com/quarkusio/quarkus/issues/22919#issuecomment-1169815274
NOTE: Weird SSH Issues on a Mac
I ran into some weird issues when I recreated the VM with more memory and couldn’t ssh into the VM.
stephennimmo@~ % podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
ssh: Could not resolve hostname localhost: nodename nor servname provided, or not known
After looking all around the /etc/hosts
file, restarting the machine, and trying explicitely sshing into the machine with ssh -i ~/.ssh/podman-machine-default core@localhost:<port>
, I found the ssh config file documentation and added an entry to it. This solved the problem.
stephennimmo@~ % touch ~/.ssh/config
stephennimmo@~ % chmod 600 ~/.ssh/config
stephennimmo@~ % vi ~/.ssh/config
Host localhost
HostName 127.0.0.1
:wq!
Reference: https://linuxize.com/post/using-the-ssh-config-file