Declaring Independence from Docker Desktop with Docker Engine
Today is July 4, which is Independence Day here in the United States. Depending on which history book you read, it’s either when the plucky United States declared independence from tyranical British rule or it’s when a rogue colony no longer appreciated the benevolence of its caretaker from across the sea.
Either way, today we can declare independence from Docker Desktop for Windows containers! While Docker Desktop provides some niceties and creature comforts, if you’re a command-line person like me, the UI and such aren’t much more than some extra and unnecessary processor cycles being spent. Often Docker Desktop also ships updates that tend to break containers for whatever reason and the auto-update feature becomes more of a roulette wheel than anything else. Lastly, if you didn’t realize, Docker Desktop now requires a paid license if you’re working in a larger organization.
Fortunately, there is an open-source project called Docker Engine, which is what Windows Server runs under the hood to run containers. Basically, if all you’re using Docker for is to run containers from the command-line, this is a nice easy option to take. Docker actually provides instructions to do so on its website, albeit intentionally difficult to find.
Installation
Installation is super easy. Download the latest version of the binaries from the Docker website and extract into a folder, like C:\docker
.
To register the Docker daemon as a Windows service, go into the folder you extracted your binaries and execute the following (as Administrator):
dockerd.exe --register-service
This will create a Windows service for the Docker daemon. Now, Docker should initialize at system startup. At this point you can manually start the service or reboot to let it start automatically.
I’d also recommend you setting your PATH
environment variable to point to the folder you extracted the binaries in so that you have access to docker.exe
anywhere in your system.
At this point you can use all your docker
commands. Go nuts.
Docker Compose
What about Docker Compose? How do you get that installed? That’s easy as well.
You can download the docker-compose.exe
binary using the instructions on the Docker website or directly from their GitHub releases page. You should wind up with an .exe
file. Rename that .exe
file to docker-compose.exe
and place the file in the C:\Program Files\Docker\cli-plugins
folder.
Restart your Docker daemon (e.g. docker
Windows service) and now you should have docker compose
available for use!
Upgrading
To upgrade is just as easy:
- Download the latest binaries from the Docker website
- Stop your daemon/service
- Replace the binaries with the newer version
- Restart your daemon/service
The same process works for upgrading Docker Compose as well. To downgrade, it’s the same process, just with an older version of the binaries.
Specifying a data folder
By default, Docker stores your container data and files in C:\ProgramData\docker
on Windows, which can compete with disk I/O and storage with your operating system if you have a lot of containers. You can have Docker store the container images and other data in another specified location.
You’ll need to create a daemon.json
file in C:\ProgramData\docker\config
with the following contents:
{
"data-root": "D:\\docker"
}
This will cause Docker to use D:\docker
as the root directory to store all of your data. Note that you need to escape the slash with another slash. Also, if you already have images downloaded and such, you’ll need to redownload them again after changing locations. Theoretically you can move your existing files over but I’ve seen issues with that - you’re probably better off just starting from scratch.
Running Linux containers
One thing Docker Desktop allowed you to do was to run Linux containers via WSL2. You know what else can run Docker containers in WSL2? That’s right, Docker engine. Now that WSL2 has support for <code>systemd</code>, regular Docker engine runs great on it.
Consider yourself freed from Docker Desktop! There might be other bits of functionality that Docker Desktop has that isn’t covered in here, but if all you’re using it for is to run containers and especially if you live in the command-line anyways, you can get all the features and none of the fat by using Docker Engine!