Here’s a quickie realization for folks like me who naively figured it would be easy to integrate my Windows and Mac VS Code users with Docker. This realization resulted in me building a bare-metal Linux box to make everything work a lot easier for our Docker lab.
Docker Is Easy, Usually
It’s easy for most engineers to use Docker if you are working on one platform. If you’re working exclusively in Windows, MacOS or Linux, then you’re probably not going to hit the speed bump I’m about to describe.
This advice will resonate for IT pros who need to integrate Docker into an enterprise with Mac and Windows developers.
Ignore The Windows Docker Strategy
Sometimes I get led astray in my devops studies because I am lured into a vendor strategy.
I see a shiny object that makes me feel better. I am like a fish chasing a lure because this newfangled vendor strategy promises me things will be glorious once I buy into the strategy. What really happens is that I get hooked on the vendor’s offering.
If you are working with Node, PHP, or Golang to build a cloud app, then you should know that the Windows Docker strategy is crap.
The containerization “strategy” announced by Docker and Microsoft in 2017 is a good example of vendors luring in IT pros with talk of nirvana. Here is that strategy in a nutshell: if you want to run Windows servers within a Docker container, that is now possible. You still need Hyper-V running underneath Docker on a Windows 2016 server, so whatever.
Hopefully this little realization will save someone else the time and bother I wasted going down a few rabbit holes.
Linux Rules Devops
As it is with all things devops, it is always best to go back to mother, i.e. Linux.
After studying the Docker documentation and tuning my network, I realized that I needed Docker to run on a dedicated Linux platform. If I told my Docker clients that DOCKER_HOST was the Linux server, I figured I might have a solution that worked! SPOILER ALERT — It does and it’s spectacular.
Here’s the real zinger that got me to set up a dedicated server. The documentation on setting up networks and exposing containers is for Linux. The Docker networking instructions give solutions using
Set Up Your Docker Lab Server
Take note that I am using an open, unauthenticated port on the Docker server for control communication, which Docker does not recommend. You can implement TLS security on your ports to tighten things up if needed.
I went with a bare metal Linux installation for a couple of reasons. First, Docker involves the use of virtualization technology, and it’s always best to avoid nesting virtualizations. Also, just about any spare PC will do for this lab setup. Even a five-year-old desktop with a 120 GB SSD will be an awesome Linux lab server.
I only spent an hour sitting in the lab setting up my new server. I used the latest LTS version of Ubuntu, but several Linux distros may be used for your Docker Linux host. If you use another distro, then check for distribution-specific instructions for how to open Docker port 2375.
To set up a simple Mac and Windows Docker lab without security, follow these instructions.
- Start with a working VS Code installation on Mac and Windows.
- Install Docker locally on both Mac and Windows developer workstations.
- Integrate VS Code with Docker on Mac and Windows. Make sure you have the Docker extension installed and working properly.
- Prepare a bare-metal server from the distribution ISO with Ubuntu Server 18.04 LTS.
- Assign the server a fixed, private IP, such as 10.0.0.20.
- Remove AppArmor on the Linux server to improve performance.
- Follow these instructions to install Docker-CE.
- To open up port 2375 update the following system files and reboot your server (source).
# File: /etc/default/docker
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="tcp://10.0.0.20:2375 -H unix:///var/run/docker.sock"
# File: /lib/systemd/system/docker.service
## Add EnviromentFile + add "$DOCKER_OPTS" at end of ExecStart
## After change exec "systemctl daemon-reload"
ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS
Update Mac and Windows Environments
Start configuring your clients by adding the following line to your
.bashrc files on the Mac:
On Windows, go into the System control panel, Advanced Settings, Environment Variables and add the following:
If you are using Windows Subsystem for Linux (WSL), and you use Docker with WSL, then add the
export statement to your
.bashrc files too.
Restart VS Code and any terminal or shell programs you have running. Launch a new shell and test it with
docker info. You should see Ubuntu 18.04 OS listed in the output.
First, double-check the
export statements and Environment Variable settings in your client environments. Make sure you have the “:2375” on the end.
If you have doubts whether you have successfully opened up port 2375 on your Linux server check the port manually. First, make sure you have
telnet installed on your Windows, Mac or WSL. Issue this
telnet command to see if the port on host 10.0.0.20 is open.
$ telnet 10.0.0.20 2375
If the port is open, then
telnet will continue to run and you will need to quit it with CTRL-C or CTRL-]. If the port is not open, then you will get a communication refused error message.
After installing your new host, disable the Docker daemons running on Mac and Windows. The Docker CLI works without the local servers running.
Now it’s time to bask in the glory of your conquest. Run into the next office and claim victory!