Also, learn how to use Portainer as an alternative Docker GUI
As a developer who switched from Linux to Windows for many reasons, I've been using Docker Desktop for a few months because it automatically updates my Docker environment.
Unfortunately this is no longer possible and I have to remove Docker Desktop.
Luckily I haven't used Docker Desktop for any commands or functionality other than updating the Docker engine, so this change won't impact my workflow.
Docker has updated itsDocker Desktop License Agreementand enable professional use of Docker Desktop in large organizations without a paid Docker subscription. So if your company has more than 250 employees or more than $10 million in annual revenue, you won't be able to use Docker Desktop without a paid subscription. It remains free for small businesses, personal use, open source projects, and educational purposes.
This license update applies only to Docker Desktop and not to Docker or Docker Engine. This way, you can continue to use Docker for development and all kinds of environments, including production. Normally, this license update will not affect your company's business when working with Docker.
To follow this procedure, you need a WSL2 compatible workstation like Windows 10 version 2004 or later. To check which version is installed, pressWindows-Logo-Key + R
and press Enter to view your system settings. If you don't meet the requirements, update your Windows.
If Docker Desktop is installed, you must uninstall it
On Windows, the Linux subsystem must be enabled. This can be done by pressing the buttonWindows registry key, type "Turn Windows features on and off" and open it.
Scroll down and toggle the feature on if it's off.
Once activated, press OK and restart your computer.
You can also install the Linux subsystem with a PowerShell command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
After configuring the prerequisite, you need to open a PowerShell with administrative privileges and install Ubuntu on WSL2 with the following command:
wsl --set-default-version 2
wsl --install -d Ubuntu
You can also install various Linux submodules in this step.
After the installation is complete, you need to verify that Ubuntu was installed on the correct version:
wsl-l-v
If everything worked correctly, your Ubuntu should be installed with the appropriate WSL version. If the version is not correct, you can change it with:
wsl --set-version ubuntu-JJ.MM 2
YY.MM is the version of the version of Ubuntu you recently installed.
To install Docker on Windows within the Ubuntu submodule, you can follow the official steps to install Docker on Ubuntu:
Another option is to create a new file and copy the following script into it. These commands are simply copied from the official tutorial into a file to share with other developers.
Go to your Ubuntu submodule in PowerShell and run the file to install Docker and the required dependencies.
Now you can start and check if everything is working correctly with:
sudo service docker start # Start engine
sudo service docker status # gives good status information
docker run hello-world # Run a test docker container
After the last command finishes, you should see the output of the running Docker image:
If you install Ubuntu as your WSL2 distribution and use at least one based on Ubuntu Hirsute Hippo (21.04), your docker daemon may not start properly.
while trying to walkStauer
produces the following error log:
...
INFO[2021-09-25T15:06:20.839195000+08:00] Loading containers: Start.
INFO[2021-09-25T15:06:20.885624800+08:00] Stop event flow after graceful shutdown error="<nil>" module=libcontainerd namespace=moby
INFO [2021-09-25T15:06:20.885865900+08:00] Stop integrity check after graceful shutdown module=libcontainerd
INFO[2021-09-25T15:06:20.886012400+08:00] Stop event flow after graceful shutdown Error = "Context aborted" Module = libcontainerd Namespace = plugins.moby
Error starting daemon: Error initializing network driver: Error getting driver instance: Error adding return rule in chain DOCKER-ISOLATION-STAGE-1: (iptables failed: iptables --wait - A DOCKER-ISOLATION-STAGE- 1 -j RETURN : iptables v1.8.7 (nf_tables): RULE_APPEND failed (no such file or directory): rule chain DOCKER-ISOLATION-STAGE-1
(initial state 4))
I realize itiptables
used by Docker is anftables
Execution. This resulted in an error because Ubuntu from version 20.10 changed the firewall system tonftables
(You couldread about it on this website). Unfortunately withnftables
natively requires Linux kernel 5.8, but the latest kernel version for WSL is 5.4.
Fortunately, Ubuntu still has the option of using a legacy version ofiptables
currently running:
$ sudo update-alternatives --config iptablesThere are 2 options for alternate iptables (providing /usr/sbin/iptables).Selection route priority status
-------------------------------------------------- ----------
* 0 /usr/sbin/iptables-nft 20 Auto-Modus
1 /usr/sbin/iptables-legacy 10 Modo-Handbuch
2 /usr/sbin/iptables-nft 20 Modo manualPress <Enter> to keep the current selection[*] or type the selection number: 1
Upgrade alternatives: Use /usr/sbin/iptables-legacy to mount /usr/sbin/iptables (iptables) in manual mode
After updating theiptables
Just restart the docker daemon and you will find that docker is working properly.
Docker Compose can be installed from within the Ubuntu submodule. Open a PowerShell window and switch to the Ubuntu submodule. Then download the latest version from GitHub:
$ sudo curl -L https://github.com/docker/compose/releases/download/2.4.1/docker-compose-`name -s`-`name -m` -o /usr/local/bin/docker -compose
Next, grant permissions to run the docker-compose command:
sudo chmod +x /usr/local/bin/docker-compose
You can then test the functionality by running itdocker-compose-version
inside the Ubuntu submodule orwsl docker-compose-version
from any PowerShell window.
If you follow the tutorial you should have:
- WSL2 Linux subsystem installed
- Docker installed and configured on Ubuntu
- Docker Compose installed
You can use any Docker command inside your Ubuntu submodule and also inside a PowerShell by prefixing the command with awsl
:
wsl-ps-Docker
wsl docker-compose-version
For convenience, you should be able to use any docker command without addingwsl
before. To achieve this, you can create an alias for your PowerShell.Read about it hereand configure everything.
Then locate your PowerShell profile
echo $PROFILE
and open this file in an editor and paste this content:
function start-wsldocker {
wsl docker $argumente
}
function home WslDockerCompose {
wsl docker $argumente
}Set-Alias-DockerName-Value Home-WslDocker
Set-Alias -Name docker-compose -Wert Home-WslDockerCompose
Save the file and restart your PowerShell terminal to test if the alias is working by typing:
pd-Docker
docker-compose-version
If you don't get an error, it's working as expected.
To better replace Docker Desktop and have something like a Docker GUI, consider installing Portainer in your local environment.
Portainer is a powerful GUI-based container-as-a-service solution that enables companies to easily and securely manage and deploy cloud-native applications.
With Porttainer you can:
- Deploy apps with defined app templates (click to deploy)
- Deploy and manage stacks from compose files, including deploying directly from Git
- Deploy and manage containers, including the ability to edit a running container
- Drag/Push/Create images
- create networks
- Create/Delete Volumes
- View a Docker event log
- View Docker Engine (host) information and apply security checks as needed
This Docker Compose file can be used to install Portainer CE as a Docker service that will automatically restart when not running.
# docker-compose.yml
Version: '3'Services:
wear:
Picture: portainer/portainer-ce:latest
container_name: portainer
Reboot: unless stopped
Security option:
- no new privileges: true
Volume:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./portainer-data:/data
Ports:
- 9000:9000
Save it in any folder and run it in your PowerShell:
docker-compose up -d
Switch to your browser and open ithttp://localhost:9000.
Time notice:Make sure to log in and create your credentials shortly after Portainer is ready or it will automatically shut down for security reasons. If you didn't create the credentials in time and it shuts down automatically, you need to restart the service.
advantage
There are several advantages over the Docker desktop version:
- The Docker engine is free. Therefore, upgrading the license is not a problem for your development and production environment.
- Portainer is production-ready software for managing your Docker environment, which is also commonly used in a server cluster environment.
- You will learn the basics of Docker much faster and acquire more DevOps skills.
- Production environments often run on Linux, so your development environment is closer to the production environment.
In contrast
The only downside for me is that you have to manually update it yourself instead of clicking the "OK" button when a new version is available.
Thank you for reading this article!
I hope you enjoyed reading it and now you can install the Docker environment on your Windows host in the Ubuntu submodule. Also, I hope you can now use and install Portainer and Docker Compose on Windows. If it works for you, I'd love to get your feedback in the comments section. If you have any questions, write them down below. I will answer if possible.
This article was published on my blog athttps://www.paulsblog.dev/how-to-install-docker-sin-docker-desktop-on-windows/
Do you want to connect?If you are interested, please feel free to contact me atmy personal website,blood,LinkedIn, jGitHub!
FAQs
Is there an alternative to Docker desktop? ›
Rancher Desktop is a Docker Desktop alternative for Mac, Windows, and Linux. It features a built-in GUI and is easy to use. The container runtime used by Kubernetes and Rancher Desktop is similar. Rancher Desktop offers container management for building, pushing, and running containers.
Is it possible to install Docker in Windows? ›Install Docker Desktop on Windows
If you haven't already downloaded the installer ( Docker Desktop Installer.exe ), you can get it from Docker Hub. It typically downloads to your Downloads folder, or you can run it from the recent downloads bar at the bottom of your web browser.
Google solves this problem by providing a tool called Kaniko. Kaniko helps you build container images within a container without any access to the Docker daemon. That way, you can execute your build jobs within containers without granting any access to the host filesystem.
Is Docker for Windows the same as Docker desktop? ›Docker Desktop for Windows is a product meant for running both Linux and Windows containers on Windows. It's not meant for a production environment, and instead is meant for a desktop/client SKU of Windows, hence the Windows 10 requirement. So you could think of this as Docker for Windows 10.
Is Docker free without Docker desktop? ›It remains free for smaller companies, private use, open-source projects, and educational purposes. This license update is only related to Docker Desktop and not to Docker or the Docker Engine. This enables you to still use Docker for development and all types of environments, including the production ones.
Is Docker free without desktop? ›Basically, if your company has 250+ employees or makes more than $10 million in annual revenue, you will not be able to use Docker Desktop without the paid subscription. It remains free for smaller companies, private use, educational purposes and open-source projects.