Docker
Lovely Kumari
DevOps & Cloud Engineer | AWS | Azure | Terraform | Kubernetes | Docker | CI/CD | GitLab | From Crowd to Cloud????
Docker
Docker, represented by a logo with a friendly looking whale, is an open-source centralized platform designed to create, deploy and run applications.
# Advantages of Docker: -
COMPONENTS OF DOCKER
1. Docker Daemon
2. Docker Client: - Docker users can interact with Docker Daemon through a Docker Client (CLI).
3. Docker Host: - Docker Host is used to provide an environment to execute and run applications.
DOCKER HUB/REGISTRY
Docker registry manages and stores the Docker Images.
There are two types of registries in the Docker:
1. ? ? ? Public Registry: - It is also called Docker Hub.
2. ? ? ? Private Registry: - It is used to share images within the enterprise.
DOCKER IMAGES
Docker images are the read only binary templates used to create Docker Containers.
OR
??Single file with all dependencies and configurations required to run a program.
# WAYS TO CREATE AN IMAGE
1. Take an image from Docker Hub.
# docker run -it ubuntu /bin/bash
2. Create image from Dockerfile.
# docker build -t image .
3. Create image from existing docker container.
???????????# docker commit containername image?
DOCKER CONTAINERS
??The container holds the entire packages that are needed to run the application.
???????OR
??In other words, we can say that the image is a template and the container is a copy of that template.
# BASIC COMMANDS
To install docker - yum install docker -y
To check version of the docker - docker -v
To see all the images, present in your local machine - docker images
To find out images (eg. jenkins) in docker hub - docker search jenkins
To download image from Docker Hub to local machine - docker pull jenkins
To give name to a Container - docker run -it --name containername ubuntu /bin/bash
To check, service is start or not - service docker status
To start container - docker start container_name
领英推荐
To go inside container - docker attach container_name
To see all the containers - docker ps -a
To see only running containers - docker ps
To stop container - docker stop containername
To delete container - docker rm containername
Dockerfile is basically a text file. It contains some information.
#DOCKER COMPONENTS
1.? ? ? ? Container - Container
2.? ? ? ? Host - Container
?# Creating Volume from Dockerfile
?Create a Dockerfile and write:
???FROM ubuntu
???VOLUME [ "/myvolume"]
?For sharing volume across containers
# docker run -it --name container2 --privileged=true --volumes-from container1 ubuntu /bin/bash
?Creating volume by using Command
# docker run -it --name container3 -v /volume2 ubuntu /bin/bash
?Create one more container and share volume2
# docker run -it --name container4 --privileged=true --volumes-from container3 ubuntu /bin/bash
?#DOCKER PORT
Create a container and attach Host and Container port to it
# docker run -td --name myconntainer -p 80:80 ubuntu?
?PUSH/PULL IMAGES IN DOCKERHUB
Docker login
First, give tag to your image
# docker tag image1 dockerid/newimage
?Push command
# docker push dockerid/newimage
?For pulling the same image in another account
# docker pull dockerid/newimage
?For making a container using that image
# docker run -it --name mycontainer dockerid/newimage /bin/bash
Stop running all containers
# docker stop $(docker ps -a -q)
Delete all stopped containers
# docker rm $(docker ps -a -q)
Delete all images
# docker rmi -f $(docker images -q)
Securing Application | Shifting Left | DevSecOps
2 年Congratulations ?? in first writeup buddy Keep it up ??