Motivation
Docker recently updated its terms making the Docker Desktop for macOS and Windows free only for personal use. Any business with more than 250 employees or more than $10 million annual revenue needs to buy its Docker Business subscription. For me, the Docker Desktop was already a hit and a miss. It was great when it worked but a pain to troubleshoot when it did not. Also, it does not bode well when they make software based on open source tools paid after it was free for a long time. Now is the time to find an alternative for this.
PhotonOS
If you read my previous post on PhotonOS
, you would know how impressed I was with it. This is a perfect use case for such a lightweight operating system, being targetted at container workloads. So that’s what we will use to create this alternative for the Docker Desktop. I will go through two hypervisor configurations, Oracle VirtualBox (free) and VMware Fusion Pro (not free, needs a license). Before proceeding, download the Minimal ISO x86_64 PhotonOS ISO from Github
. For this setup to also work over VPN connections, port forwarding is necessary. Otherwise, the DOCKER_HOST
can point directly to the VM’s IP address to simplify configuration.
Installing PhotonOS: Oracle VirtualBox
VirtualBox is much easier in terms of configuring port forwards and shared folders. Follow the steps below to get started.
Start by creating a new VM. Provide it a name and select Linux/Linux 2.6/3.x/4.x (64-bit)
Select the Memory size. I prefer to keep this at 1 or 2 GB
Create a virtual hard disk now. Accept the defaults of VDI and dynamically size by hitting Continue
Select the size of the hard disk. I prefer a 20G disk that I can increase if need be
Once done, click on Settings for the new VM
Under Storage, Select Empty under Controller: IDE. Click on the CD icon beside the Optical drive option to Choose a disk file and select the photonOS minimal ISO downloaded before
Under Network, expand Advanced and click on Port Forwarding. Click on the green + icon to add a new forwarding for the Docker API, select TCP protocol, leave the Host IP empty, enter 2375 for the Host Port, leave the Guest IP empty, and enter 2375 for the Guest Port. Click OK to complete the configuration
Under Shared Folders, click the green + icon to add a new share and select your home folder for the Folder Path. Copy this folder path and paste it in the Mount point section. Enable Auto-mount and click OK
Continue to follow the common installation section
Installing PhotonOS: VMWare Fusion Pro
VMware Fusion Pro does not make it easy to customize shared folders, create static IP configs and add port forwarding we need. Follow step 0 to create a new network that we will customize later and proceed.
- Click on VMware Fusion in the menu bar and select Preferences
- Under Network, click the lock icon to unlock the settings
- Click on the + icon to add a new network.
- Enable Allow virtual machines on this network to connect to external networks (using NAT)
- Apply the changes. Note down the network adapter name needed for post-installation. It is of the format
vmnetX
. For me, it wasvmnet3
- Now start by creating a new virtual machine by File > New. Drag and drop the downloaded ISO image here and select continue
- For the boot firmware, select UEFI, but do not select UEFI Secure Boot as the keys needed for it won’t be enrolled
- In the next page, click on Customize Settings, give the VM a name and accept or change where the VM would be stored. Once done, click Finish
- Now, you would see a VM Settings window show up. If not, click on the Virtual Machine on the menu bar and click on Settings
- Here, we need to configure a couple of things
In Sharing, enable Shared Folders, and add a new share. This will be your Home directory, so that you can mount files from macOS to docker. Let the permission be Read/Write
In Processors & Memory, change the settings based on your usage. I prefer to allocate two processor cores and 1 or 2 GB of Memory
In Network Adapter, select the adapter created in step 0. For me, it was vmnet3
In Hard Disk (SCSI), increase the Disk size. All the docker images that we pull are stored here. I prefer to keep it at 20G and increase it if needed. Remember to hit Apply here
In Advanced, enable the checkbox to Disable Side Channel Mitigations. See the VMware KB article for more details
- Continue to follow the common installation section
Installing PhotonOS: Common
Power on the VM and hit Enter to begin the installation.
- Hit Enter to Accept the Licence Agreement
- Hit Enter to Auto Select the disk partitions
- Hit Enter to Proceed with automatic network configuration
- If using VMware Fusion, you will see an additional configuration choice. Here, you can choose the VMware hypervisor optimized kernel
- Provide a hostname. I keep it simple, for example:
photon-docker
- Provide a root password to use later while logging in
- Select Yes to continue with the installation
This will be done in less than a minute. It took me just 20 seconds! Once done, hit enter to reboot and login with root
and the password set in the previous step to continue with configuring PhotonOS
if using VirtualBox or follow post installation steps for VMware Fusion Pro
.
Post-installation: VMware Fusion Pro
Once the installation of Photon OS is complete, we need to configure a static IP address for the VM to enable port forwarding. Power off the VM and follow the steps below.
From Virtual Machine Settings (Virtual Machine > Settings), head over to Network Adapter
Expand Advanced options to copy the MAC address shown
From a terminal, run the below commands to open up an editor. Remember to replace vmnetX with the name noted down before installation
1 2
cd /Library/Preferences/VMware\ Fusion/vmnetX sudo nano dhcpd.conf
Find the section which shows the subnet. A sample is shown below. Change the last octet to choose a static IP for your VM. Keep the number between 3 and 127 since the rest of the range is used by DHCP. I choose
172.16.88.3
in my example1 2 3
subnet 172.16.88.0 netmask 255.255.255.0 { ... }
Scroll down to the very end of the file and add the text shown below. Replace the MAC address
00:00:00:00:00:00
with the MAC address of the VM copied in step 2. Replace the IP address172.16.88.3
with an IP address chosen in step 41 2 3 4
host PhotonOS { hardware ethernet 00:00:00:00:00:00; fixed-address 172.16.88.3; }
Save and exit nano by pressing the sequence
Ctrl+X
,Y
,Enter
Restart VMware Fusion Pro by quitting the app and relaunching it for the DHCP configuration changes to take effect
Click on VMware Fusion > Preferences. Under Network, select the one created before. In my case,
vmnet3
. Click the lock icon to edit the configurationClick + to add an entry in the Port Forwarding table for the Docker API. Host port is 2375, Type is TCP, Virtual machine IP address is the one chosen in step 4 and the Virtual machine port is 2375. Provide a description and hit OK
Add any further ports you might need to expose from docker. You can do this any time, even when the VM is powered on. I added 8080 as I most commonly publish services to port 8080
Power on the VM and login with root credentials
To make sharing as seamless are possible, let us configure a soft link for the share we created earlier
1 2 3 4 5
ln -s /mnt/hgfs /Users # This command should show your username as a mounted share and show your files in the home folder ls /Users ls /Users/*
Continue with Configuring PhotonOS .
Configuring PhotonOS
To configure docker to listen on the TCP port along with the unix socket at /var/run/docker.sock
, run the commands below from the PhotonOS console
|
|
To validate if this configuration change worked, run the below command. It should correctly show the docker version without any errors.
|
|
Configuring the macOS host
You should now be able to use docker from your macOS terminal! To do so, open the Terminal on macOS, install the docker cli from homebrew and add the environment variable to be used at startup using the commands below.
|
|
And that’s it! You have a fully functioning docker desktop replacement, batteries included. Just remember to add more port forwards if you need to expose services from docker containers to be accessible from the host.