Setting up Docker
In today’s development environment, containerization has become an essential practice for developers and IT professionals. Docker, one of the leading containerization platforms, allows us to automate the deployment of applications inside lightweight, portable, and self-sufficient containers. This technology not only simplifies the process of managing application dependencies and packages but also ensures that your application works cross-platform.
In this tutorial, we will guide you through the step-by-step process of setting up Docker on your system. Whether you are a new developer looking to learn about Docker or a seasoned one, this tutorial will guide you through the setup process for the following operating systems:
- Mac
- Windows
- Linux
Docker setup for Mac
To set up Docker in MacOS, open the official Docker website to download the Docker desktop. Once the download is completed, install it on your Mac system.
Once the installation is done, run the Docker desktop and open your terminal. In the terminal run the command docker –version
to see the current version of Docker. Run docker run hello-world
to confirm containers are working.
Docker setup for Windows
In Windows, the procedure for setting up Docker is the following:
- You will have to make sure Windows features required to run Docker are enabled. To turn these on search
Turn Windows features on or off
and open it. - Once it is open, select the options called
Hyper-V
andWindows Subsystem for Linux
Press OK to restart your system.
Once this is done, download the Docker desktop from Docker website and install it.
After installation, if your PC doesn’t have
WSL
enabled, you will get an error message like this:
To fix the problem, you must copy the given command in the error message and paste it inside
PowerShell
. Make sure to runPowerShell
as administrator. Once you run the command, your system will restart.With this, the installation of Docker is done. To confirm it is working run the following two commands:
Docker setup for Linux
When it comes to Linux, you must be careful as Docker only supports Ubuntu, Debian, Red Hat Enterprise Linux (RHEL), and Fedora. You can follow the steps below to setup Docker on Linux:
Checking the KVM Virtualization Support
- To load the module, run:
modprobe kvm
- Depending on your CPU, the next command will differ:
modprobe kvm_intel # Intel processorsmodprobe kvm_amd # AMD processors
- To check if the KVM module is working, run the Command:
lsmod | grep kvm
The following steps require you to set up KVM device user permissions:
- You will have to check the ownership of
/dev/kvm
and to do that, run:
ls -al /dev/kvm
- The next step requires you to add your user name,
$USER
, to the kvm group:
sudo usermod -aG kvm $USER
You are done with checking the KVM. Now we will move to setting up the Docker Desktop.
Setting up the Docker Desktop in Linux
- First, you need to update your package database. To do that, run:
sudo apt get-update
- Install the Docker engine like so:
sudo apt install docker.io
- Once the above installation is done, you need to enable the docker services. To do that, run the following commands:
sudo systemctl enable docker
To confirm that the docker services are running, run the command:
sudo systemctl status
Note: If the services are not running, run the command:
sudo systemctl start docker
- Finally, to check if Docker is running, run a Docker container like so:
sudo docker run hello-world
- You should get a response like this:
Conclusion
Congratulations! In this article, we’ve walked through setting up a Docker container for Mac, Windows, and Linux—the first step towards mastering Docker. With Docker, you’re now equipped to create consistent and isolated environments for your applications, making development, testing, and deployment more efficient and reliable.
To learn more about computer science concepts, check out these articles on Codecademy.
Author
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Meet the full team