Docker_Notes-day2
Docker_Notes-day2
Docker Editions:
Type: Containerization
Vendor: Docker INC
DockerContainer --> Run time instance of an image.If you run docker image container
will be created
that's where our application(process) is running.
DockerRegistriy/Repository
Public Repo --> Docker hub is a public reposotiry. Which contains all the open
source softwares as
a docker images. We can think of docker hub as play store for docker images.
Docker Enigine/Daemon/Host --> It's a software or program using which we can create
images & contianers.
Docker is cross platform.
Docker CE
Docker CE will not be supported by Redhat.
Docker EE
Docker EE will be support most of the os including redhat.
# You will get permison denied error as regular user dosn't have permisions to
execute docker commands.Add user to docker group.
# Exit From Current SSH Terminal & SSH(Login) again .Then execute
docker ps
# Amazon Linux
================
sudo yum update -y
sudo yum install docker -y
sudo service docker start
ex:
sudo usermod -aG docker ec2-user
Once you add user to group exit from the server and login again.
# Get docker information
docker info
# You will get permison denied error as regular user dosn't have permisions to
execute docker commands.Add user to docker group.
# Exit From Current SSH Terminal & SSH(Login) again .Then execute
docker ps
# List Images
docker images
FROM tomcat:8-jdk8-corretto
COPY target/maven-web-application*.war /usr/local/tomcat/webapps/maven-web-
application.war
# Build Image
Defautl Docker file Name: Dockefile
docker build -t <imageName> .
If you have docker file with custom name using -f <fileName> while building docker
image.
docker build -f DockerfileMaven -t <imageName> .
Note: Image name should have repository details along with name and version.
Public Repo (Docker Hub)
ex:
docker build -t dockerhandson/maven-web-application .
ex:
docker build -t 178.90.34.12:8083/maven-web-application .
# Public Repo
docker login -u <userName> -p <password>
ex:
docker login -u dockerhandson -p password
Priavate Repo
docker login -u <username> -p <password> <URL>
ex:
docker login -u admin -p admin123 178.90.34.12:8083
Public Repo
docker push dockerhandson/maven-web-application
Private Repo
docker push 178.90.34.12:8083/maven-web-application
=============
# List Images
docker images
docker image ls
FROM tomcat:8-jdk8-corretto
COPY target/maven-web-application*.war /usr/local/tomcat/webapps/maven-web-
application.war
# Build Image
Defautl Docker file Name: Dockefile
docker build -t <imageName> .
If you have docker file with custom name using -f <fileName> while building docker
image.
docker build -f DockerfileMaven -t <imageName> .
Note: Image name should have repository details along with name and version.
ex:
docker build -t dockerhandson/maven-web-application .
ex:
docker build -t 178.90.34.12:8083/maven-web-application .
# Public Repo
docker login -u <userName> -p <password>
ex:
docker login -u dockerhandson -p password
Priavate Repo
docker login -u <username> -p <password> <URL>
ex:
docker login -u admin -p admin123 178.90.34.12:8083
Public Repo
docker push dockerhandson/maven-web-application
Private Repo
docker push 178.90.34.12:8083/maven-web-application
# Downlod Image from repo
docker pull <imageName>
Public Repo
docker pull dockerhandson/maven-web-application
Private Repo
docker pull 178.90.34.12:8083/maven-web-application
Delete Image
Note: We cann't remove images if there are running container for the image.We
cann't force delete images if there is running container.
If container is in stopped(exited) state we can force delete image for the stopped
container.
# In destination server
docker load -i <fileName>.tar
ECR
===
docker build -t 935840844891.dkr.ecr.ap-south-1.amazonaws.com/maven-web-app
Note: Create IAM Role with required policy and attach to EC2 Servers.