-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocker commands.txt
119 lines (62 loc) · 4.33 KB
/
Docker commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
https://hub.docker.com/
1) Commands
Check Docker version : docker version
Login docker : docker login
List container : docker ps -a
List images : docker images/ docker images ls
Docker build image : docker build -t(for name of the template) .
Docker run : docker run (image name ) / docker run (image name ) : (tag) {default tag is latest}
Docker run with input : docker run -i (image name)
Docker run with input terminal : docker run -it (image name)
Docker run container (port mapping) : docker run -p( port{new port:defined port} ) (image name )
Docker run-in detach mode : docker run -d —name=(name) (image name )
Docker run-in Attach mode : docker attach (container name ) // first few letter of id
Docker run Volume mapping : docker run -v (external path : internal path(var/lib/ ??)) image name )
Docker run on Host machine : Docker -H=(ip:port) run (image name)
Docker run cpu restriction : docker run —-cpu=0.5 (image name)
Docker run memory restriction : docker run —-memory =100m (image name)
Docker : docker service create --replace=100 (image name)
(docker run -v (vol name):/val/lib/docker (image name))
Docker bind mounting : docker run -v (path) : /val/lib/mysql (image name)
(Mount external database)
There are 2 types of mount Volume mount and directory mount : Volume mount mounts the volume in the
Stop the container : docker stop (container id)
Docker delete container : docker rm (first 3 letter of the container followed by space) / docker rm container name
Docker remove by image name : docker rmi (first 3 letter of the images followed by space)
Docker delete by image id : docker rmi -f imageid
Commit : docker commit (container id) (username)/(image id) : tag
Pull from docker hub : docker pull (image name)
Push to docker hub : docker push (image id)
Execute command in running docker : docker exec (image name) (command)
Inspect properties of running container : docker inspect (image name)
Docker image history : docker history (image name)
Docker Network : Docker network create —driver bridge —-subnet 180.18.0.1 custom-isolated-network
Docker create volume : docker volume create (vol name)
(To store the temp data of disk)

Link docker container : docker run —-name=(name) —-link (container name):(host name app looking for) (image name)
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
2) Docker File:
Docker fine contain 2 things: Instruction and Arguments
-> Instruction : FROM, RUN, COPY, ENTRYPOINT, EXPOSE, ARGS, ADD
-> Agument : Imagename, port-no, filename
Eg:
FROM openjdk:8-jdk-alpine
EXPOSE 8000
ARG JAR_FILE=target/UserService.jar
ADD ${JAR_FILE} UserService.jar
ENTRYPOINT ["java","-jar","/UserService.jar"]
Docker execute commands in layers
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
3) File System:

Layered Architecture (the first 4 layers are read only and 5 layer is read and write):
1. First layer is image name
2. Second layer Dependency if any
3. Third layer Source code
4. Update entry point of image
5. Docker contain layer

——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
Docker compose —build