Running Windows and Linux Containers Simultaneously

If you are running Sitecore in a container then you’ve most likely switched Docker desktop to Windows container mode. But what if you want to run a Linux container simultaneously? For example, you might want to fire up, JMeter and Grafana on Linux containers. It turns out this is possible in your local development environment and is fairly straightforward.

Crane lifting up container in yard

Enable Experimental Features

The experimental features are not ready for production. They are provided for test and evaluation in your sandbox environments. Before we enable let’s just do a quick check and make sure There are no containers currently running and if there are we’ll want to stop or shit them down.

docker container ls

Access the Docker Desktop Settings, select the Daemon tab and enable Experimental Features and hit Apply.

experimental

You should get a message indicating Docker Desktop is restarting.

Fire up your favorite Sitecore containers again to ensure they are still working as expected.

sitecore

sitecore

All good. Now let’s go ahead and pull down a Linux container for Grafana from Docker Hub

docker pull –platform=linux grafana/grafana

Notice I have specified the flag –platform=linux? Adding the –platform=linux flag allows the Linux container to be successfully pulled and run while running Docker in Windows Container mode.

Now we will fire up the container specifying with the –platform flag:

docker run –platform=linux -d –name=grafana -p 3000:3000 grafana/grafana

Lets check our running containers and you should see Grafana which is running in Linux:

containers

We should be able to browse Grafana http://127.0.0.1:3000

grafana_login

What happens if you disable Experimental Features and try to run a Linux container while in Windows Container mode?

You should get an error indicating “–platform” is only supported on a Docker daemon with experimental features enabled.

disable_exp_error

If you remove –platform flag you will get an error response from daemon: operating system on which parent image was created is not windows.

Useful info

Have Fun!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s