Docker Engine
Docker Engine, often referred to as Docker, is an open-source technology that provides the core runtime for building, running, and managing containers. It acts as a client-server application with three core components:
- The Docker Daemon (
dockerd)- A long-running server process responsible for managing Docker containers, images, networks, and volumes.
- The Command-Line Interface (CLI) Client (
docker)- The primary way for users to send commands and instructions to the Docker daemon (
dockerd), which performs the actual operations.
- The primary way for users to send commands and instructions to the Docker daemon (
- The REST API
- A programmatic interface for interacting with the Docker daemon. Even the Docker CLI itself uses these REST APIs under the hood to communicate with the daemon.
Docker Engine requires a Linux Kernel and so it can run natively only on Linux but not Windows/MacOS. It is ideal for production servers and headless environments (e.g., cloud instances), as it often requires manual installation and configuration.
Installation
The Docker Engine installation instructions for various Linux platforms can be found in the official docs here.
Post-installation steps
Manage Docker as a non-root user
- Create
dockergroup (This group should already exist):
sudo groupadd docker- Add your current user to the
dockergroup:
sudo usermod -aG docker $USER- Run the following command to activate the changes to groups:
If you're running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
newgrp docker- Verify that you can run
dockercommands withoutsudo:
docker run hello-worldConfigure Docker to start on boot with systemd
On Debian and Ubuntu, the Docker service starts on boot by default. To automatically start Docker and containerd on boot for other Linux distributions using systemd, run the following commands:
sudo systemctl enable docker.service
sudo systemctl enable containerd.serviceTo stop this behavior, use disable instead:
sudo systemctl disable docker.service
sudo systemctl disable containerd.serviceConfigure default logging driver
Docker uses logging drivers to collect and manage container logs. By default, it uses the json-file driver, which stores logs as JSON files on the host. Over time, these files can grow large and consume disk space.
To prevent this, you can:
- Enable log rotation for
json-fileto limit log size.- To enable log rotation, update the Docker configuration file, found at
/etc/docker/daemon.jsonon Linux, to set themax-sizeandmax-fileoptions:
- To enable log rotation, update the Docker configuration file, found at
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}- Use the
locallogging driver, which has built-in log rotation (100MB limit per container).- To do this, update
/etc/docker/daemon.jsonusing:
- To do this, update
{
"log-driver": "local",
"log-opts": {
"max-size": "10m"
}
}- Send logs to a remote logging system for centralized storage and management.
