Docker and Podman environments on Windows and Mac machines
For Young and Old
If you are running a Linux system, you will not have much trouble using either Docker or Podman as a container manager. The software is available from the repositories of almost all the well-known Linux distributions. However, the situation is different if you want to set up an environment for developing container applications on a Windows or Mac system. For this, you have to resort to external software. Docker Desktop [1] provides a Docker environment for these systems, with other components in addition to the Docker engine and the command-line client. For example, you also get the container orchestration tool Kubernetes [2] delivered free with the software.
Older Systems Locked Out
An older Windows or Mac machine, however, can be problematic. Docker Desktop requires at least Windows 10 or macOS 10.14, although you can still resort to Docker Machine [3] in this case, which creates a virtual Linux system on the local host that you can then use to access the Docker engine. The example in Figure 1 uses VirtualBox [4] on a Mac for the virtual machine setup. You can either download VirtualBox as an installation archive directly from the website, or if you want to install it on a Mac system, you can install it with the Homebrew package manager [5].
Docker Machine also gives you access to the Docker container manager independently of Docker Desktop, so you can also develop container applications. However, what does the situation look like if you want to use Podman as the container manager instead of Docker?
Podman Instead of Docker
It stands to reason that the appropriate counterpart for Docker Machine also exists for Podman. In fact, work on developing this kind of software started [6], but the project was discontinued after some time in favor of Vagrant [7]. Vagrant has long enjoyed a good reputation as a manager for virtual machines and is often used to create virtual machines based on Vagrant boxes and a Vagrantfile. The workflow required for this can be completely automated and scales very well, even if you are using a large number of virtual machines.
Listing 1 is a sample Vagrantfile that you can use to create a virtual machine; again, this is based on VirtualBox with a Fedora operating system. Inside this system, you then install the Podman software and tell it to listen for incoming requests on a Unix socket. On the Windows or Mac system, you then install only the Podman client software, which communicates with podman
on the virtual machine over the Unix socket. The complete setup of the virtual machine is handled by the Vagrantfile.
Listing 1
Vagrantfile
01 Vagrant.configure("2") do |config| config.vm.box = "fedora/33-cloud-base" 02 config.vm.provider "virtualbox" do |vb| vb.memory = "1024" 03 end 04 config.vm.provision "shell", inline: <-SHELL 05 yum install -y podman 06 groupadd -f -r podman 07 #systemctl edit podman.socket 08 mkdir -p /etc/systemd/system/podman.socket.d 09 cat >/etc/systemd/system/podman.socket.d/override.conf 10 [Socket] 11 SocketMode=0660 12 SocketUser=root 13 SocketGroup=podman 14 EOF 15 systemctl daemon-reload 16 echo "d /run/podman 0770 root podman" > /etc/tmpfiles.d/podman.conf 17 sudo systemd-tmpfiles --create 18 systemctl enable podman.socket 19 systemctl start podman.socket 20 usermod -aG podman $SUDO_USER 21 SHELL 22 end
Once you have installed both VirtualBox and Vagrant, either with Homebrew or an installation archive, save the Vagrantfile from Listing 1 under the same name in a folder of your choice (e.g., ~/podman/
). The file really must be named Vagrantfile
; otherwise, Vagrant will not find it without help. From the directory in which the file is located, simply call vagrant
to start the installation and setup of the virtual machine.
If everything has worked so far, the following command shows that a Fedora 33 Vagrant box is present on your system:
vagrant box list fedora/33-cloud-base (virtualbox, 33.20201019.0)
By the way, Vagrant stores it in the user's home directory under ~/.vagrant.d/boxes/
. Entering vagrant ssh
gets you direct shell access to the virtual machine.
Podman Client on the Host System
To manage your containers from the host system, you now need the Podman client. To get it, simply download the appropriate installation file from the website [8], or in the case of macOS, install the software by calling
brew install podman
with the Homebrew package manager.
Podman supports some environment variables, so the client software knows the host on which the Podman domain socket is available and how authentication will take place. If you use the Podman Windows client, you can simply enter the data you need directly. On a Linux or Mac machine, simply enter the following two lines in your shell configuration file (e.g., ~/.bashrc
, or ~/.zshrc
if you are on a Mac):
export CONTAINER_HOST=ssh://vagrant@127.0.0.1:2222/run/podman/podman.sock export CONTAINER_SSHKEY=/Users/tscherf/tools/podman/.vagrant/machines/default/virtualbox/private_key
Be sure to use the correct paths. This example comes from the ~/.zshrc
file on my Mac.
Finally, Figure 2 shows how you can now use Podman to manage your containers with the client to access the Podman installation inside the virtual machine.
Buy this article as PDF
(incl. VAT)
Buy ADMIN Magazine
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Most Popular
Support Our Work
ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.