Introduction to Docker
Containers are a method of building, packaging and deploying software. They are similar to but not the same thing as virtual machines (VMs). One of the primary differences is that containers are isolated or abstracted away from the underlying operating system and infrastructure that they run on. Container orchestration is the automation of much of the operational effort required to run containerized workloads and services. This includes a wide range of things software teams need to manage a container’s lifecycle, including provisioning, deployment, scaling (up and down), networking, load balancing and more. Major benefits of container orchestration is Portability, Application development and Resource utilization and optimization Docker is a specific platform for building containers, including the Docker Engine container runtime, whereas container orchestration is a broader term referring to automation of any container’s lifecycle. Docker also includes Docker Swarm, kubernetes and Apache Mesos, which is the platform’s own container orchestration tool that can automatically start Docker containers. In this article we will talk about docker and kubernetes.
Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.
Docker works by providing a standard way to run your code. Docker is an operating system for containers. Similar to how a virtual machine virtualizes (removes the need to directly manage) server hardware, containers virtualize the operating system of a server. Docker is installed on each server and provides simple commands you can use to build, start, or stop containers.
Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface. Another Docker client is Docker Compose, that lets you work with applications consisting of a set of containers.
Install Docker Engine on Ubuntu
Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
Set up the repository, Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/ docker-archive-keyring.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io
Add user to docker group and restart the terminal
sudo usermod -aG docker $USER
Building an Apache Web Server through a Dockerfile
Lets create apache image using ubuntu base image.
FROM ubuntu RUN apt update RUN apt install –y apache2 RUN apt install –y apache2-utils RUN apt clean EXPOSE 80 CMD [“apache2ctl”, “-D”, “FOREGROUND”]
Tag and Build the docker image
docker build -t apache_image:1.0 .
Run the docker image as a container
docker run --name myapache -d -p 80:80 apache_image:1.0
*This article is comprised of aggregated sources; that is, we've used the best information on the internet to provide a summary of everything you need to know. Our references are noted below.