Install and configure Docker¶
Docker allows to create containers that are independent from your operating system. This allows to embed all your software needs and ship it to someone else.
In this tutorial, you will install Docker in order to develop, build and ship your applications so that will work on other Dockers environments.
Steps¶
Docker can be installed with the following methods.
You can follow the official documentation depending on your Linux distribution.
You might want to allow non-root users to run Docker following the post-install documentation.
The Compose plugin has to be installed externally to work. You can install it with your package manager with the related documentation.
For Debian, you can execute the following commands to install Docker with the Compose plugin.
Download and install Docker Desktop from the official website. You can then start Docker Desktop and you should be good to go.
Install Windows Subsystem for Linux (WSL)¶
On Windows, it is highly recommended to install a WSL distribution. You can follow the official documentation to install your Linux distribution.
For the default Ubuntu WSL distribution, you can execute the following steps.
First, download and install the Linux kernel update package
Press the Win key. Search for Powershell. Right-click on it, and select Run as administrator. Type the following commands. You'll be asked to create a new user in the WSL Linux distribution with its password.
Verify in the Powershell that the version on WSL is the right with wsl -l -v
, the output should looks like that.
Once the process of installing your Linux distribution with WSL is complete, open the distribution Ubuntu using the Start menu. This will open a command line in your distribution. You will be asked to create a User Name and Password for your Linux distribution.
Install Docker¶
Once the WSL has been installed, download and install Docker Desktop from the official website. Restart your computer. You can then start Docker Desktop and you should be good to go.
Troubleshooting
If your Ubuntu log into a root user, it means your installation process of Ubuntu was aborted. Like NotTheDr01ds said on ask.ubuntu.com:
Quote
Option 1: Reinstall Ubuntu on WSL
If you've just recently installed and don't have any files that you don't mind losing in Ubuntu, then the best solution is going to be to simply reinstall the distribution so that it completes properly.
To do so, open a regular (non-Admin) PowerShell terminal, and ...
[...]
That will complete the installation and get you back to the point where it asks for a default username and password.
Option: 2 Recreate user manually
If you do have files and need to recover without a reinstall, you need to create a new "default" WSL user without reinstalling
As far as I (Vincent) can tell, the following will create the default user with the same settings that the stock installer/configuration does. From within Ubuntu:
Of course, modifying username
to be whatever you want. Since you are already running as root, no need for sudo
or any trickery there, of course, but other readers without the OP's use-case may need sudo
or wsl -u root
.
[...]
And then need to set the default WSL user
"Normally", the WSL distro installer (e.g. ubuntu.exe
) modifies the Windows Registry with the default user name for the distro. I recommend a newer method, though. As root, create a file /etc/wsl.conf
with the following contents:
Again, of course, substituting your username.
Summary¶
Congrats! You have successfully installed and configured Docker!
Versions¶
At the time of writing this tutorial, the versions for Docker and Docker Compose are as follow (on macOS). Yours might be more recent but it should work nonetheless.
Resources and inspirations¶
These resources and inspirations were used to create this tutorial (in alphabetical order).