Docker is an open-source software platform that enables developers to build, run, test, and deploy applications quickly. Your application or software is packaged into standardized units called containers. The container contains everything that’s needed to run the software including libraries, system tools, code, and other dependencies.
Basically, docker helps to separate your application from your infrastructure. You can manage your infrastructure in the docker itself as per your need.
Your application doesn’t have to rely on what’s installed on your host machine. Your application only depends on what’s on the docker container and the docker containers are sharable between people. So, everyone will have the same tools installed in the shared containers.
Docker Architecture
- Docker uses a client-server architecture.
- The Docker client talks to the Docker daemon.
- Docker daemon is responsible for building, running, and distributing docker containers.
- The Docker client and daemon can run on the same system, or the docker client can also be connected to the 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, which lets you work with applications consisting of a set of containers.
- Read more: https://docs.docker.com/get-started/overview/
Display System Wide Information
docker info
Display docker version
docker version
Docker Tools & Terminologies
Below are some of the terms we encounter while using docker:
Docker Daemon
- The Docker daemon (
dockerd
) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes.
Docker Client
- The Docker client (
docker
) is the primary way that many Docker users interact with Docker. - When you use commands such as docker run, the docker client sends these commands to docker daemon (
dockerd
), which carries them out. - The docker command uses the Docker API.
- The Docker client can communicate with more than one daemon.
Docker Image
- A docker image contains all the tools, libraries, and dependencies required to run the application source code.
- Docker images can be created from scratch but the most command practice is to pull from common online repositories.
- It’s a read-only template with instructions for creating a Docker container.
- Multiple docker images can be created from a single base image.
- Docker Images are made up of layers.
- Each layer corresponds to a version of the image.
- Every time a docker container is created from the docker image, a new layer is added to the image. It’s called the container layer.
- The files added, updated, and deleted in the container are saved in the container layer and exist only while the container is running.
Example:
Docker official image of Ubuntu Linux OS: https://hub.docker.com/_/ubuntu
List all the images in your system
docker images
Docker Container
- Docker containers are the running instance of Docker Images.
- Docker containers are writable and executable.
List active containers
docker ps
List all (active and inactive) containers
docker ps -a
Docker Volume
- Docker Volume is a storage mechanism to store the data generated by Docker containers.
- It is better to store data in a docker volume than to store it in the container because if the container is destroyed then all the data will also get destroyed if the data is stored in the container.
- Docker volume can be shared with multiple containers.
List all volumes
docker volume ls
DockerFile
- It’s a simple text file containing instructions on how to build the docker container image.
- It contains a list of command-line interface (CLI) instructions.
- The docker engine will run those commands to build the image.
Example Dockerfile
FROM php:fpm
RUN docker-php-ext-install pdo pdo_mysql
RUN pecl install xdebug && docker-php-ext-enable xdebug
Docker Hub
- Docker Hub is the public repository of docker images.
- It contains docker images produced by Docker Inc. and certified images from other vendors as well.
- Normal users can also upload their own docker images to the docker hub.
Docker Registry
- It’s an open-source storage and distribution system for Docker images.
- It stores docker images.
docker run
ordocker pull
pulls the docker image from the configured registry.docker push
pushes the docker image from the configured registry.
Docker Desktop
- Docker Desktop is an easy-to-install application for Mac, Linux, or Windows environments.
- It’s an alternative to the use of CLI to manage containers and applications.
- It provides a simple interface that enables you to manage your containers, applications, and images directly from your machine without having to use the CLI to perform core actions.
Docker Compose
- Docker Compose is used to manage multiple containers of an application.
- It uses a YAML file where the containers and host can be specified.
Example docker-compose.yml
file
version: '3'
services:
web:
image: nginx:latest
ports:
- "80:80"
Hope this helps. Thanks.