Install DOCKER in Centos or Ubuntu
$ sudo yum -y update
$ sudo yum install -y docker (For CentOS)
$ sudo apt-get install -y docker.io (For Ubuntu)
$ docker --version
$ service docker start
$ systemctl enable docker
$ service docker status
Images Commands
$ docker images
$ docker pull ubuntu:20.04
$ docker rmi image-id
Containers Commands
$ docker ps
$ docker ps -a
$ docker run --name demo-container -it image-id /bin/bash
$ docker run --name demo-container -it -d image-id /bin/bash
$ docker attach Container-ID
$ docker start Container-ID
$ docker stop Container-ID
$ docker rm Container-ID
$ docker diff Container-ID
$ docker rename Container-Name New-Container-Name
$ docker exec -it Container-ID /bin/bash Enter into Existing Container
$ docker stop $(docker ps -a -q) Stop All Running Container
$ docker rm $(docker ps -a -q) Delete All Stoped Container
$ docker rmi -f $(docker images -q) Delete All Images
Docker Volume Commands
$ docker volume
$ docker volume create Volume-Name
$ docker volume ls
$ docker run --name Container-Name -it -v Volume-Name:/var/www/html/local-vol Image-ID /bin/bash
$ docker volume location in system /var/lib/docker/volumes/
$ docker run --name Container-Name -it -v /home/ec2-user/Volume-Name:/var/www/html/local-vol Image-ID /bin/bash
$ docker run --name Container-Name -it -v Volume-Name:/var/www/html/local-vol -p 81:80 -p 3307:3306 Image-ID /bin/bash
$ docker run --name Container-Name -it -v Volume-Name:/var/www/html/local-vol -p 82:80 -p 3308:3306 Image-ID /bin/bash
$ docker-compose --version
$ docker-compose config Validate the docker-compose.yml
$ docker-compose up -d
$ docker compose down
$ docker commit Container-ID New-Image-Name
$ docker login
$ docker tag Image-ID Docker-ID/New-Image-Name
$ docker push Docker-ID/New-Image-Name
$ docker pull Docker-ID/New-Image-Name
$ docker stats Container-ID
$ docker system df Container-ID
$ docker system prune Remove All Unused And Stoped Container
No comments:
Post a Comment
testing