Docker Containers
Docker is a software platform for building and running applications inside isolated environments called containers. It packages an application together with its dependencies into a lightweight, portable unit that can run consistently across environments without requiring major configuration changes.
A container is a self-contained unit that bundles an application's source code and dependencies. It can be started or moved between environments quickly and efficiently. Unlike a virtual machine, which requires a separate operating system for each instance, a container shares the host kernel and includes only what the application needs.
- Portability: Run the same containerized application across multiple environments, including cloud platforms, with minimal configuration changes.
- Efficient resource usage: Docker containers are lighter than virtual machines because they do not require a dedicated hypervisor and operating system for each workload.
- Operating system compatibility: Docker can run on non-Linux systems, but its performance and behavior may differ from a native Linux environment.
- Orchestration complexity: Managing larger deployments requires additional tooling, such as Docker Swarm or Kubernetes, which introduces a steeper learning curve.
-
Update the package index and install
curland certificate packages.bashsudo apt-get update sudo apt-get install ca-certificates curl -y -
Configure Docker's GPG key so packages can be verified against the official repository.
bashsudo 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 -
Add the official Docker repository.
bashecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null -
Install Docker Engine and its supporting components.
bashsudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y -
Allow the current non-root user to run Docker commands.
bashsudo usermod -aG docker $USER sudo chmod 666 /var/run/docker.sock docker version