← Back to Blog

Running Apps in Docker for Mac

In an earlier post I wrote instructions for running graphical applications out of Docker containers on my Mac. Since I wrote that post, I have wiped my Mac and reinstalled everything, including Docker for Mac. This post is an update of those instructions.

The steps for running graphical applications from Docker on a Mac have simplified quite a bit. These instructions assume you have Docker for Mac installed and running and have access to container images. Without further ado, here are the instructions:

  1. Install XQuartz from https://www.xquartz.org/. This MUST be done. The separate installation is required for the graphical applications to run on the Mac host from a Docker container.

  2. Logout and log back into the Mac. This is necessary to use XQuartz.

  3. Open XQuartz. From a terminal, execute the following command:

    open -a XQuartz
    
  4. In the XQuartz terminal window, execute the command:

    xhost +
    

This command may be a little insecure; I haven't researched it fully yet. 5. Run your Docker container, passing the DISPLAY environment variable with a command like:

     docker run --rm -it -e DISPLAY=192.168.1.1:0 ubuntu:latest /bin/bash

192.168.1.1 is a sample IP address. Use the IP address of your system there. 6. Within the Docker container, run an application with a graphical interface. This should display on the Mac. 7. Enjoy!

← Back to Blog