Skip to main content

Day 16 Task: Docker for DevOps Engineers.

Published 4 min readMarkdown
Day 16 Task: Docker for DevOps Engineers.

What is Docker?

It is a software development platform.

Here you package the app in the image.

The container uses the image to start the application.

Container run on any operating system.

It works the same independently of os, machine, and environment.

Lightweight compared to VM.

Easier to maintain and deploy.

Docker runs with any language, os, or runtime.

Docker Workflow:-

Docker Components:-

  1. Docker client and server:-

The communication between the Docker client and the Docker host is via a REST API. You can issue similar commands, such as a Docker Pull command, which would send an instruction to the daemon and perform the operation by interacting with other components (image, container, registry).

  1. Docker image:-

    A Docker image is a template that contains instructions for the Docker container. That template is written in a language called YAML, which stands for Yet Another Markup Language.

  2. Docker registry:-

    The Docker registry is where you would host various types of images and where you would distribute the images from. The repository itself is just a collection of Docker images, which are built on instructions written in YAML and are very easily stored and shared. You can give the Docker images name tags so that it’s easy for people to find and share them within the Docker registry. One way to start managing a registry is to use the publicly accessible Docker hub registry, which is available to anybody. You can also create your registry for your use internally.

  3. Docker container:-

    The Docker container is an executable package of applications and their dependencies bundled together; it gives all the instructions for the solution you’re looking to run. It’s lightweight due to the built-in structural redundancy. The container is also inherently portable. Another benefit is that it runs completely in isolation. Even if you are running a container, it’s guaranteed not to be impacted by any host OS securities or unique setups, unlike with a virtual machine or a non-containerized environment. The memory for a Docker environment can be shared across multiple containers, which is useful, especially when you have a virtual machine that has a defined amount of memory for each environment.

Advanced Docker Components:-

  1. Docker compose:-

    Docker is designed for running multiple containers as a single service. It does so by running each container in isolation but allowing the containers to interact with one another. As noted earlier, you would write the compose environments using YAML.

  2. Docker swamp:-

    is a service for containers that allows IT administrators and developers to create and manage a cluster of swarm nodes within the Docker platform. Each node of the Docker swarm is a Docker daemon, and all Docker daemons interact using the Docker API. A swarm consists of two types of nodes: a manager node and a worker node. A manager node maintains cluster management tasks. Worker nodes receive and execute tasks from the manager node.

Following are steps to install docker in AWS EC2:-

  1. sudo apt-get update

  2. sudo apt-get install docker.io

  3. docker ps
    In this command you will get an error of permission so proceed with the next command.

  4. sudo usermod -aG docker $USER

  5. sudo reboot

  6. docker ps
    The error is gone now and you will get some container names here.

  7. docker pull mysql

  8. docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=test@123 mysql: latest
    For installing MySQL step 7 & 8 is used.

  9. docker ps
    After this, you will be able to see the name of the MySQL instance.

docker ps:- It is used to list the running container by default.

Task:

  1. Docker run

The docker run command to start a new container and interact with it through the command line. Check below run command u can rn MySQL container.

eg. docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=test@123 mysql: latest

  1. Docker images

It will display all the available images.

  1. Docker inspect

The docker inspect command to view detailed information about a container or image.

  1. Docker Stats

The docker stats command to view resource usage statistics for one or more containers.

  1. Docker Save

The docker save command to save an image to a tar archive.

  1. Docker Load

The docker load command to load an image from a tar archive.

  1. Docker top

    The Docker top command provides information about the CPU, memory, and swap usage if you run it inside a Docker container:

About the author

No comments yet. Be the first to comment.

More from this blog