Testcontainers with Rancher Desktop

Posted on Jan 31, 2024

Docker migration

Introduction #

Since August 2021, Docker has revised its licensing terms, making it no longer free for certain users. In this post, I’ll walk you through the steps to migrate to Rancher Desktop, an alternative that might suit your needs in the wake of these changes. This guide aims to help you smoothly transition from Docker Desktop to Rancher Desktop.

Why migrate from Docker Desktop? #

Docker’s updated licensing terms have prompted many to explore alternatives. They’ve introduced new pricing tiers depending on your organization’s size and needs. For larger businesses (more than 250 employees or over $10 million in annual revenue), a paid subscription is required:

Plan Annual costs per user
Pro $60
Team $108
Business $288

For a company with around 80 engineers, the annual cost of the Team Plan would be $8,640. The Business plan would set you back $23,040 a year. The alternative, in this case Rancher Desktop is free and open-source.

Migrating to Rancher Desktop #

Testcontainers relies on the presence of the file /var/run/docker.sock. To facilitate this, it’s necessary to give administrative rights, which allows Rancher Desktop to automatically create the symlink for you. You can enable these permissions by going to the settings Preferences/Application/General in Rancher Desktop and choosing the “Allow to acquire administrative credentials (sudo access)” option.

There’s an easy way to test whether everything is working as expected by running docker ps in the default context. Let’s first list the contexts by running docker context ls:

bash
NAME                DESCRIPTION                               DOCKER ENDPOINT
default             Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
rancher-desktop *   Rancher Desktop moby context              unix:///Users/my-username/.rd/docker.sock

Chances are that rancher-desktop is your default context (ending with an asterix). Let’s switch to the default context by running docker context use default.

If you now execute docker ps, you will see the results below:

bash
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS          PORTS                                                  NAMES

If you see the message below then Testcontainer most likely does not have administrator rights, and was unable to create the required symlink at /var/run/docker.sock:

bash
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Troubleshooting #

If you encounter a “too long for Unix domain socket” error when starting Ranger Desktop, you will need to execute two commands to resolve this issue:

bash
mv ~/Library/Application\ Support/rancher-desktop/lima ~/.rdlima
ln -s ~/.rdlima ~/Library/Application\ Support/rancher-desktop/lima

The first command moves the Rancher Desktop files to a new location. The second command links these files back to their original location.

Conclusion #

By following these steps, you can successfully migrate from Docker Desktop to Rancher Desktop. This switch can be particularly beneficial for larger organizations looking to manage their software development costs effectively.