[go: up one dir, main page]

0% found this document useful (0 votes)
12 views3 pages

Docker Commands

This document provides a comprehensive guide on installing and using Docker, including commands for installation, managing images, running containers, and working with volumes. It also covers Docker Compose for orchestrating multi-container applications and troubleshooting tips. Additionally, it includes practical examples of Docker commands for various tasks.

Uploaded by

naveen.t2412
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Docker Commands

This document provides a comprehensive guide on installing and using Docker, including commands for installation, managing images, running containers, and working with volumes. It also covers Docker Compose for orchestrating multi-container applications and troubleshooting tips. Additionally, it includes practical examples of Docker commands for various tasks.

Uploaded by

naveen.t2412
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

install docker

sudo yum -y update


sudo yum install -y docker
docker
docker --version

Or

sudo apt-get remove docker docker-engine docker.io


sudo apt-get update
sudo apt install docker.io
docker -v
sudo chmod 666 /var/run/docker.sock

docker login
------------------------
Docker Images

docker images
docker pull centos:latest
docker pull ubuntu:latest
docker pull nginx:latest

docker run -it ubuntu /bin/bash


exit
docker exec -it containerid /bin/bash

docker tag imagid imagename


docker push anbhiman/ddemo
docker rmi imageid
----------------

docker ps
docker ps -a
docker run ImageName
docker start ContainerName/ID
docker stop ContainerName/ID
docker rm ContainerName/ID

-----

Volumes-

docker volume
docker volume create myvolumm1
docker volume ls
docker volume inspect myvolumm1
docker volume rm myvolumm1
docker volume prune

-----------------------------------------------
docker compose -

docker-compose -v
mkdir mydockercompose
cd mydockercompose
touch docker-compose.yml
version: '3.4'
services:
database:
image: redis
ports:
- 9090:80
web:
image: nginx

docker-compose up -d
docker-compose down

sudo apt install lynx


lynx localhost:9090

docker-compose up -d --scale database=4

if any error install docker compose agin

sudo apt install docker.io docker-compose

------------------------------------------------
docker logs

docker logs CONTAINERid


docker logs 6cc871763df1 --details

Docker Logs Location -


/var/lib/docker/containers/<container_id>/<container_id>-json.log

--------------------------------------------------
connect volume to container
docker run -v /ram:/tmp ubuntu:latest

docker run -it --name=example1 --mount source=v1,destination=/v1 ubuntu

---------------------------------------------------------------------

BY Practice

20 docker pull ubuntu:latest


21 docker images
22 docker login
23 sudo chmod 666 /var/run/docker.sock
24 docker login
25 doccker images
26 docker images
27 docker tag 27941809078c
28 docker tag 27941809078c sarath261/ubuntu
29 docker images
30 docker push sarath261/ubuntu
31 docker run -it --name ubuntu1 sarath261/ubuntu:latest /bin/bash
32 systemctl start docker
33 docker images
34 docker ps -a

38 docker start cf02d0d6bcd6


39 docker ps
40 docker exec -it cf02d0d6bcd6 /bin/bash
41 docker run -itd sarath/ubuntu
42 docker ps -a
43 docker ps
44 docker stop cf02d0d6bcd6
45 docker run -itd sarath261/ubuntu:latest
46 docker ps

51 docker volume inspect raj


52 cd /var/lib/docker/volumes/raj/_data
53 touch a1
54 ls
55 vim a1
56 docker rmi ram
57 docker volume rm ram
58 docker volume ls

64 docker volume create raj1


65 docker volume create raj2
66 docker volume create raj3
67 docker volume ls
68 docker volume prune -> it will delete all empty containers

69 docker volume ls
70 docker volume create ram
71 docker run -v ram:/tmp sarath261/ubuntu:latest
72 cd ..
73 docker ps
74 docker exec -it 74ecc831398b /bin/bash
75 docker volume inspect ram
76 cd /var/lib/docker/volumes/ram/_data
77 ls
78 touch a1
79 vi a1
80 ls
81 cd ..
82 docker exec -it 74ecc831398b /bin/bash

You might also like