## ----- Docker overview ----------##
Docker is an open platform for developing, shipping, and running applications.
Docker enables you to separate your applications from your infrastructure so you
can deliver software quickly. With Docker, you can manage your infrastructure in
the same ways you manage your applications. By taking advantage of Docker's
methodologies for shipping, testing, and deploying code, you can significantly
reduce the delay between writing code and running it in production.
-----docker install process -------
sudo amazon-linux-extras install docker # if linux 2
sudo yum install docker -y # If linux 20203
sudo systemctl start docker
sudo systemctl status docker
Note : By default Docker works with the root user and other users can only access
to Docker with sudo commands. However, we can bypass the sudo commands by creating
a new group with the name docker and add ec2_user.
#First let’s create the docker group
sudo groupadd docker (optional if group is not created)
#Now let’s add ec2-user to docker group
sudo usermod -a -G docker ec2-user
#In order to enable the changes, run the following command
newgrp docker
sudo chmod 666 /var/run/docker.sock # to give access docker demon to run docker
server
docker --version to check docker version
#If you want to see an extended version of the version details, such as the API
version, Go version, and Engine Version, use the version command without dashes.
give below command
docker version
docker pull image <imagename>
docker pull nginx or ubuntu
docker inspect image nginx ### to check images details
docker images # to check list of images
docker ps ## to check running containers
docker ps -a ## to check both running and stopped containers
docker run -it imagename /bin/bash --will enter into the container interact
terminal
docker run -dt imagename /bin/bash -we are not enter into the container detach
terminal
docker run -dt --name <name> <imagename> /bin/bash (to give csutome name)
1.if you want to come out from connainer without stop give "ctrl+pq"
2.if you give "exit" container also will stop
ps -ef --to know how many processors runing if it is in vm many process we can
see but it is in container onle few becuase its light weight
ps -ef | wc -l #to know number of processors request running backend
#### how to start container#####
docker start <containerid>
or
docker start <container name>
#### how to stop container#####
docker stop <containerid>
or
docker stop <container name>
## docker kill comeplete terminated
docker kill <containername>
#### To login container #####
docker exec -it <continername or continerid> /bin/bash
## docker system prune -a to remove all images
## docker container prune -- delete all stoped containers
## docker rm -f $(docker ps -a -q) ---delete all runnig containers Note: please
dont use danger command
docker rm <containername or continerid> ### to remover stopped container
docker rmi <imagename> ##to delete image
docker rm -f <continer id> delete runing continer
docker run -p <HOST_PORT>:<CONTAINER:PORT> IMAGE_NAME