When using Docker for Mac, you're actually using a tiny (custom) Alpine Linux running in a special xhyve VM on macOS. There's so much cool. Apr 16, 2017 Much faster than any Virtual Machine, Docker allows you to run a Ubuntu image and gain interactive access to its shell, so you can have all your dependencies in an.
This tip applies to anyone running Docker for Windows or Docker for Mac.
And BLAMO, you’re inside of the MobyLinux VM’s file system (aka Docker Desktop).
Now if you run ls -la
you’ll see all sorts of things, such as your mounts. In Docker Tip #69 I talked about protecting against Docker’s container logs from eating up all of your disk space. This was how I figured how much space was being used on my Windows system.
I ran du -chs /var/lib/docker/containers/*/*json.log
inside of the container we’re in now, which tallies up the total disk space used by all container logs.
By the way, you can press CTRL +D
twice to exit the container. Once to exit what chroot /root
did, which was to change the root directory to point to the MobyLinux VM instead of Alpine, and again to exit the Alpine session.
If you use Linux as your host operating system then with one or two commands you can have most graphical Linux applications up and running on your desktop in seconds. Package managers like apt-get
, yum
and pacman
make installing new software almost seamless. If you are running an XWindows server (which you probably are) then getting a graphical application to appear on your screen from a remote Linux system or a Docker container can be as simple as setting the DISPLAY
environmental variable.
Many applications that exist for Linux also exist for Mac: Chrome, FireFox, VLC Player, Slack, Arduino IDE etc. In some cases they have been ported and re-built natively and even optimized to take advantage of the OS.
So why would you want to run Linux versions of apps on your Mac?
Here are a few reasons why you may want to use Docker to run Linux applications on macOS:
Since Docker provides a sandboxed environment for applications that means you can add/remove just the capabilities you want and tighten up on security.
Several paid tools exist for macOS to isolate network traffic and push it down different HTTP proxies or SOCKS tunnels depending on custom rulesets. This is ideal if you frequently work on public WiFi networks or behind a restrictive corporate network. By using your own hosted proxy server or VPN you can protect some or all of your traffic. So why pay for something you can do for free with Docker?
Slack for Linux running on the Mac Desktop in El Captain
Here's what you need to do to bring X11 to your Desktop.
An X11 server exists for MacOS which allows applications like XTerm to run and display output on your local computer. It's packaged up as the XQuartz project and can be installed with brew:
Once you have XQuartz set up you can then install your favourite graphical Linux apps into a Debian container or whichever distribution you prefer.
This is due to the fact that they generally work with a specific version of the game and after updating it or choosing another language they may (although do not have to) stop working or even malfunction.Extra care should be taken with modifications, trainers, and other things that were not created by the game’s developers. Popular files for Crysis 3NameTypeSizeDateTotal7 daystrainer148.5 KB3/6/201463.4K815trainer591.2 KB4/17/201329K504trainer1.9 MB3/20/201312K103trainer589.5 KB3/6/20135K64trainer2.3 MB8/22/201314.2K54trainer2.3 MB7/31/20136.5K45trainer147.5 KB4/17/20132.9K32trainer1.9 MB7/31/20132.7K30trainer589.2 KB2/26/20135.9K26trainer147.5 KB3/6/20135.2K20trainer1.9 MB4/10/20133.3K20trainer1.9 MB3/6/20132.9K17trainer147.5 KB3/13/20133.9K16trainer1.9 MB3/13/20131.8K15trainer1.9 MB9/11/20135.9K15trainer3.3 MB2/26/20132.7K14. In this case the possibility of malfunctioning or even damaging the game, which may necessitate reinstalling the game, is particularly high. Crysis 3 pc patch 1.4. Note: The cheats and tricks listed above may not necessarily work with your copy of the game.
Best of all, our many of our VR gaming systems also give you the power work on files, surf the web, connect via social media and more – making them multi-functional devices that are designed for the way you live.
I adapted this Dockerfile from one that Jess Frazelle came up with. It appeared to be broken when I tried it so I've added some more packages to fix the runtimes errors I encountered.
You may also be asking yourself why I've added slack from the local filesystem instead of using wget
or curl
. If you need to fetch the binary from a specific HTTP proxy or VPN tunnel then you may not want Docker to handle that.
Run this before building the Dockerfile or move it back into the file itself as a RUN
step:
Most packages are available in package repositories or PPAs so apt-get
could be used, but Slack is an exception to the rule.
By default XQuartz will listen on a UNIX socket, which is private and only exists on local our filesystem. This means Docker won't be able to access it.
Install and run socat
to create a tunnel from an open X11 port (6000) through to the local UNIX socket where XQuartz is listening for connections:
This will block, so open a new tab or terminal.
Build your Dockerfile, then start it by passing in an environmental variable for the DISPLAY
so your graphical application knows where to show itself. Change the IP address of 192.168.0.15 to whatever you see on ifconfig
.
For extra points you could:
-v /home/alex/.slack:/root/.config/slack
DISPLAY
variable.docker-compose.yml
file for easy starting/stopping of the application. (See below)If you want an app such as Slack to use a HTTP_PROXY then you can pass in the environmental variable at runtime. Here's an example with a docker-compose.yml
file for convenience:
docker-compose.yml
X11 forwarding from Docker to Linux is fast and can be accelerated by sharing additional resources such as /dev/video0
or /dev/shm
, unfortunately this is not possible with Docker on macOS. When forwarding apps from Docker to XQuartz you may find that they do not run correctly or have unexpected lag. This may be because hardware acceleration and use of the GPU is not available, but the applications may still be useable enough for you to get the benefits.
Most of what I've outlined above came from reading a Github issue from 2015: Docker issue #8710.
For examples of running popular Linux apps on the Linux Desktop see Jess' Containers on the Desktop blog post.
Let me know if you know of any way of accelerating the performance of X11-forwarded apps on macOS. Or if you have any other tips or hacks, send me a tweet @alexellisuk or post a comment.