Thursday 3 October 2019

Introducing Docker with Installation Commands


Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Docker containers are lightweight alternatives to Virtual Machine and it uses the host OS. You don't have to pre-allocate any RAM in containers.




Difference between Virtualization and Containerization:

Refer the below diagram for more understanding.


    Virtualization Containerization


Architecture Diagram of Docker



Docker Components :

1. Docker File

  1. Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

2. Docker Registry
  1. Docker registry is a storage component of Docker images.
  2. We can store the images in either public and private repositories.
  3. Docker Hub is a Docker’s very own cloud repository.

3. Docker Images
  1. Read only template used to create containers.
  2. Stored in docker hub or your local registry.

4. Docker Containers
  1. Isolated Application Platform.
  2. Contains everything needed to run the application.

Docker installation commands for beginners. How to install Docker on ubuntu :

1. Update the software repository.
  • sudo apt-get update

2. Uninstall any older docker packages and software of docker before installation of new docker packages.
  • sudo apt-get remove docker docker-engine docker.io

3. Install the docker, enter the below command in the terminal.
  • sudo apt-get install docker.io

4. The Docker service needs to be setup to run at startup. Enter the following commands.
  • sudo systemctl start docker
  • sudo systemctl enable docker
  • systemctl status docker

5. We can check the version of docker.
  • docker --version

6. We can pull any type of images from docker hub or we can create our own docker image from docker file. Here we have pulled the ubuntu image from docker hub, kindly refer the below command.
  • docker pull ubuntu
  • docker images (using this command we can list the images that we have pulled from docker hub.)

7. After getting the image we need to run that images to create the container. [Note: we can create number of containers from single docker image for multi tier architecture]. Refer the below command to run the docker image.
  • docker run --name ubuntu-server -d -p 80:80 -t ubuntu [Explanation: port forwarding, network port:container port and given the ubuntu-server as container name.
  • docker ps -a [list the containers name and from which images we have created the containers along with port and status]

8. Once the container ready we need to enter in container. Refer the below command.
  • docker exec -it ubuntu-server bash [example: container name: ubuntu-server. Put the same name of container that you have given at the time of creating the container]

9. We have successfully entered into the container.now we can work with the container whatever we want to run. [Install the web servers and all.]

10. To remove container
  • docker rm ubuntu-server

11. To check the IP address of containers.
  • sudo docker inspect container_id.

12. To stop docker
  • docker stop ubuntu-server

We hope that this article will help you understand basic Docker information. If you have any queries related to Docker then do let us know.

No comments:

Post a Comment

Maximizing Content Delivery Efficiency: Optimizing Performance in AWS CloudFront

  Unleash Blazing-Fast Content Delivery: Your Guide to CloudFront Optimization Introduction: AWS CloudFront stands as a cornerstone of moder...