DOCKER
DOCKER
â—Ź Docker the container runtime and orchestration technology.
â—Ź Docker an open source project (this is now called Moby), generated the most
interest in container technology in the past few years.
â—Ź A command line tool that made creating and working with containers easy for
developers and administrators.
â—Ź Docker is software that runs on Windows and Linux.
â—Ź It creates, manages and orchestrate containers.
Containers VS VM:
CONTAINERS VS VM
â—Ź Each virtual machine runs a unique guest operating system
â—Ź Each VM has its own binaries, libraries, and applications
â—Ź Container systems usually provide service isolation between containers.
â—Ź Containers provide a way to run these isolated systems on a single server or
host OS.
â—Ź Containers sit on top of a physical server and its host OS. Containers are only
megabytes in size and take just seconds to start, not like VM.
INTRODUCTION TO CONTAINERS
â—Ź Container technology, also known as just a container, is a method to
package an application.
â—Ź Any application can be bundled in a container can run without any worries
about dependencies, libraries and binaries.
â—Ź Container creates the isolated environment with all the required
dependencies, libraries and binaries to run your application without any issue.
â—Ź The application can run in any environment.
INTRODUCTION TO CONTAINERS
â—Ź A container is a standard unit of software that packages up a given code and
all its dependencies so the application runs quickly and reliably from one
computing environment to another.
â—Ź Containerization is a lightweight alternative to a virtual machine that involves
encapsulating an application in a container with its own operating system.
â—Ź Containerization is the process of bundling your application code with requires
packages/libraries required at runtime to execute your application quickly and
reliably in any supported computing environment
INTRODUCTION TO CONTAINERS
Monolithic applications are proved to be hard maintained, maintaining and CI/CD of
such applications is time and energy intensive.
Containerization offers the following benefits:
â—Ź Portability of distributed applications
â—Ź Reproducibility of the application
â—Ź Scaling based on requirements
â—Ź Lifecycle management of containers
â—Ź Memory, CPU, and storage efficiency compared to VM hosting and hence cluster
improvisation
Visualizing Docker’s Architecture
Visualizing Docker’s Architecture
â—Ź The Docker Daemon
â—‹ Docker daemon is a service that runs on your host operating system.
â—Ź Docker Daemon REST API
â—‹ The Docker daemon itself exposes a REST API From here, a number of
different tools can talk to the daemon through this API.
â—Ź Docker CLI
â—‹ The most widespread tool is the Docker CLI. It is a command line tool
that lets you talk to the Docker daemon. When you install Docker, you get
both the Docker daemon and the Docker CLI tools together.
Images
â—Ź A Docker image is an object that contains an OS file system and an
application.
● A container image is an inert, immutable, file that’s essentially a binary
packaged snapshot of a container.
â—Ź An image is the application we want to run.
â—Ź It is like a virtual machine template.
â—Ź You can think of an image as a class.
Docker Installation
â—Ź Official Ubuntu Repositories
â—‹ $ sudo apt-get install docker.io
â—Ź Another Way TO install Docker from Official Site
â—‹ https://docs.docker.com/install/linux/docker-ce/ubuntu/
â—Ź Verify the installation
â—‹ $ sudo docker -v
DOCKER
â—Ź Verify that Docker CE is installed correctly by running the hello-world
image.
â—‹ $ sudo docker run hello-world
â—Ź CHECK IMAGES:
â—‹ $ sudo docker image ls
â—‹ $ sudo docker images
DOCKER COMMANDS`
â—Ź docker image pull ubuntu:latest
â—Ź docker images or docker image ls
â—Ź docker container run -it ubuntu:latest
â—Ź ps -elf
â—Ź touch myfile.txt
â—Ź pressed Ctrl-PQ
â—Ź docker container ls (copy the container name)
â—Ź docker exec -it <container-name> bash
â—Ź Stop the container and kill it using the docker container stop and docker
container rm commands.
â—‹ docker container stop <container-name>
â—‹ docker stop $(docker ps -a -q)
â—‹ docker container start <container-name>
â—‹ docker container rm <container-name>
â—Ź Verify that the container was successfully deleted by running another docker
container ls command.
â—‹ docker container ls
DOCKER COMMANDS
To Build Docker Image:
Create index.html file
Hello EveryOne.
To Build Docker Image:
â—Ź Create Dockerfile
â—‹ Add the following Instructions in Dockerfile:
â—‹ FROM instruction to set the application's base image.
â–  FROM nginx:alpine
â—‹ COPY files from a specific location into a Docker image.
â–  COPY index.html /usr/share/nginx/html/index.html
To Build Docker Image:
â—Ź BUILD IMAGE:
â—‹ The "-t" flag adds a tag to the image so that it gets a nice name and tag.
○ At the end in the below command “.” which tells Docker to use the
Dockerfile in the current directory.
â—Ź docker image build -t <image-name> .
DOCKER
â—Ź CHECK IMAGES AGAIN:
â—‹ $ sudo docker image ls
â—Ź Run IMAGE:
â—‹ Get Image Name from above command.
â–  $ sudo docker container run -p=8080:80 <image-name>
â—‹ To run the container in the background
â–  $ sudo docker container run -d --name <container-name> -p=8080:80 <image>
DOCKER-HUB
â—Ź Create account on Docker-hub.
â—‹ https://hub.docker.com/
â—Ź Login to docker hub.
â—Ź Now connect your machine to docker hub using this command:
â—‹ $ sudo docker login --username=yourhubusername --email=youremail@company.com
â—Ź Create repository on docker hub.
DOCKER-HUB
â—Ź Check the image ID using:
â—‹ $ sudo docker images
â—Ź Tag your image using:
â—‹ $ sudo docker tag <image-id> yourhubusername/repository-name:tag
â—Ź Push your image to the repository you created.
â—‹ $ sudo docker push yourhubusername/repository-name:tag
DOCKER COMMANDS
â—Ź docker image ls
â—‹ To get the list of images
â—Ź docker pull
â—‹ Pull an image from the registry.
â—‹ docker pull <image-name>
â—Ź docker run
â—‹ docker run command to launch a container.
DOCKER COMMANDS
docker container run -it --name os1 ubuntu:latest bash
exit
docker exec -it os1 bash
docker start os1
docker exec -it os1 bash
docker volume create <volume-name>
docker volume ls
docker run -d -p 84:80 -v <vol-name>/:/usr/share/nginx/html/ 22061996/hello-world:v5
DOCKER Volume
docker run -d -p=8080:80 -v prac:/usr/share/nginx/html --name prac
22061996/hello-world:v5
THANKS

DOCKER-PIAIC-SLIDES

  • 1.
  • 2.
    DOCKER â—Ź Docker thecontainer runtime and orchestration technology. â—Ź Docker an open source project (this is now called Moby), generated the most interest in container technology in the past few years. â—Ź A command line tool that made creating and working with containers easy for developers and administrators. â—Ź Docker is software that runs on Windows and Linux. â—Ź It creates, manages and orchestrate containers.
  • 3.
  • 4.
    CONTAINERS VS VM â—ŹEach virtual machine runs a unique guest operating system â—Ź Each VM has its own binaries, libraries, and applications â—Ź Container systems usually provide service isolation between containers. â—Ź Containers provide a way to run these isolated systems on a single server or host OS. â—Ź Containers sit on top of a physical server and its host OS. Containers are only megabytes in size and take just seconds to start, not like VM.
  • 5.
    INTRODUCTION TO CONTAINERS â—ŹContainer technology, also known as just a container, is a method to package an application. â—Ź Any application can be bundled in a container can run without any worries about dependencies, libraries and binaries. â—Ź Container creates the isolated environment with all the required dependencies, libraries and binaries to run your application without any issue. â—Ź The application can run in any environment.
  • 6.
    INTRODUCTION TO CONTAINERS â—ŹA container is a standard unit of software that packages up a given code and all its dependencies so the application runs quickly and reliably from one computing environment to another. â—Ź Containerization is a lightweight alternative to a virtual machine that involves encapsulating an application in a container with its own operating system. â—Ź Containerization is the process of bundling your application code with requires packages/libraries required at runtime to execute your application quickly and reliably in any supported computing environment
  • 7.
    INTRODUCTION TO CONTAINERS Monolithicapplications are proved to be hard maintained, maintaining and CI/CD of such applications is time and energy intensive. Containerization offers the following benefits: â—Ź Portability of distributed applications â—Ź Reproducibility of the application â—Ź Scaling based on requirements â—Ź Lifecycle management of containers â—Ź Memory, CPU, and storage efficiency compared to VM hosting and hence cluster improvisation
  • 8.
  • 9.
    Visualizing Docker’s Architecture ●The Docker Daemon ○ Docker daemon is a service that runs on your host operating system. ● Docker Daemon REST API ○ The Docker daemon itself exposes a REST API From here, a number of different tools can talk to the daemon through this API. ● Docker CLI ○ The most widespread tool is the Docker CLI. It is a command line tool that lets you talk to the Docker daemon. When you install Docker, you get both the Docker daemon and the Docker CLI tools together.
  • 10.
    Images ● A Dockerimage is an object that contains an OS file system and an application. ● A container image is an inert, immutable, file that’s essentially a binary packaged snapshot of a container. ● An image is the application we want to run. ● It is like a virtual machine template. ● You can think of an image as a class.
  • 11.
    Docker Installation â—Ź OfficialUbuntu Repositories â—‹ $ sudo apt-get install docker.io â—Ź Another Way TO install Docker from Official Site â—‹ https://docs.docker.com/install/linux/docker-ce/ubuntu/ â—Ź Verify the installation â—‹ $ sudo docker -v
  • 12.
    DOCKER â—Ź Verify thatDocker CE is installed correctly by running the hello-world image. â—‹ $ sudo docker run hello-world â—Ź CHECK IMAGES: â—‹ $ sudo docker image ls â—‹ $ sudo docker images
  • 13.
    DOCKER COMMANDS` â—Ź dockerimage pull ubuntu:latest â—Ź docker images or docker image ls â—Ź docker container run -it ubuntu:latest â—Ź ps -elf â—Ź touch myfile.txt â—Ź pressed Ctrl-PQ â—Ź docker container ls (copy the container name) â—Ź docker exec -it <container-name> bash
  • 14.
    â—Ź Stop thecontainer and kill it using the docker container stop and docker container rm commands. â—‹ docker container stop <container-name> â—‹ docker stop $(docker ps -a -q) â—‹ docker container start <container-name> â—‹ docker container rm <container-name> â—Ź Verify that the container was successfully deleted by running another docker container ls command. â—‹ docker container ls DOCKER COMMANDS
  • 15.
    To Build DockerImage: Create index.html file Hello EveryOne.
  • 16.
    To Build DockerImage: â—Ź Create Dockerfile â—‹ Add the following Instructions in Dockerfile: â—‹ FROM instruction to set the application's base image. â–  FROM nginx:alpine â—‹ COPY files from a specific location into a Docker image. â–  COPY index.html /usr/share/nginx/html/index.html
  • 17.
    To Build DockerImage: ● BUILD IMAGE: ○ The "-t" flag adds a tag to the image so that it gets a nice name and tag. ○ At the end in the below command “.” which tells Docker to use the Dockerfile in the current directory. ● docker image build -t <image-name> .
  • 18.
    DOCKER â—Ź CHECK IMAGESAGAIN: â—‹ $ sudo docker image ls â—Ź Run IMAGE: â—‹ Get Image Name from above command. â–  $ sudo docker container run -p=8080:80 <image-name> â—‹ To run the container in the background â–  $ sudo docker container run -d --name <container-name> -p=8080:80 <image>
  • 19.
    DOCKER-HUB â—Ź Create accounton Docker-hub. â—‹ https://hub.docker.com/ â—Ź Login to docker hub. â—Ź Now connect your machine to docker hub using this command: â—‹ $ sudo docker login --username=yourhubusername --email=youremail@company.com â—Ź Create repository on docker hub.
  • 20.
    DOCKER-HUB â—Ź Check theimage ID using: â—‹ $ sudo docker images â—Ź Tag your image using: â—‹ $ sudo docker tag <image-id> yourhubusername/repository-name:tag â—Ź Push your image to the repository you created. â—‹ $ sudo docker push yourhubusername/repository-name:tag
  • 21.
    DOCKER COMMANDS â—Ź dockerimage ls â—‹ To get the list of images â—Ź docker pull â—‹ Pull an image from the registry. â—‹ docker pull <image-name> â—Ź docker run â—‹ docker run command to launch a container.
  • 22.
    DOCKER COMMANDS docker containerrun -it --name os1 ubuntu:latest bash exit docker exec -it os1 bash docker start os1 docker exec -it os1 bash docker volume create <volume-name> docker volume ls docker run -d -p 84:80 -v <vol-name>/:/usr/share/nginx/html/ 22061996/hello-world:v5
  • 23.
    DOCKER Volume docker run-d -p=8080:80 -v prac:/usr/share/nginx/html --name prac 22061996/hello-world:v5
  • 24.