
Docker is a tool that allows developers to build, run, verify, and share projects inside packages called Docker containers.
In addition to code, many applications and websites require additional elements such as databases, configuration files, runtime libraries, or third-party software to function properly.
With Docker, instead of having to install and configure the application itself and then each dependency for each deployment, an end user can simply pull and run a Docker container and be ready to go.
Docker runs on x86, x64, and ARM CPU architectures on macOS, Linux, and Windows. Running applications from Docker containers means you don’t need to spend time and resources building, optimizing, and maintaining builds for every possible combination of hardware and software.
Applications will run the same on any device, regardless of architectural, operating system, or configuration differences between the client machine and the original computer used to write and test the code.
Containers vs. virtual machines
There are a number of key differences between virtual machines and Docker containers. Let’s take a look at them:
Virtual machines
- Virtual machines emulate physical hardware, allowing multiple operating systems to run on a single physical machine.
- Each VM includes a complete operating system, along with the application, binaries, and libraries, creating additional overhead.
- Virtual machines require a hypervisor to manage them, which incurs some performance overhead.
- They offer strong isolation between applications since each VM has its own kernel and memory space.
Containers
- Containers virtualize the operating system instead of emulating hardware, allowing multiple applications to run on the same operating system core.
- Host machine hardware can be passed to containers to enable features like GPU acceleration, but the hardware must physically exist to do so.
- Containers package an application and all its dependencies into a single image, which is lightweight and portable.
- Containers share the host operating system kernel, resulting in lower overhead and faster startup times compared to virtual machines.
- They are very efficient and allow for higher application density on a single host.
- Containers provide less isolation compared to virtual machines since they share the same kernel.
- Docker provides version control for its containers that allows users to track versions, revert versions, and manage differences between versions.
The installation process may differ slightly depending on the VPS operating system, in this case we will see how to do it on Ubuntu 22.04:
Installing Docker
Open a terminal with root privileges and run these commands to update existing packages and configure the Docker repository:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Install the latest version of Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
To verify that the installation was successful, you can run the ‘hello-world’ image:
sudo docker run hello-world
Repositories as dockerhub and linuxserver.io host a wide variety of proprietary and community-maintained Docker images that are free to download, install, and use, and are a great place to see what’s possible.