-
Notifications
You must be signed in to change notification settings - Fork 3
/
day2.txt
475 lines (410 loc) · 9.84 KB
/
day2.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
User Name - centos
Password - centos123
IP - 13.233.121.192
============================
Jayaprasad Rao K
Kumar Shreyash
Alwin Doss
chennakeshava.s
Divya Ganesan
Vinay Kumar
Lal Kumar Koduri
Ajith Krishna R
IP - 15.207.89.139
============================
Bhargav B
ShijiVenugopal
ATUL GUPTA
Indhushree K
Abhijit Roy
Ananth P M
Pranjal Thakuria
Priyanka Sharma
================================================================
COMMANDS - https://www.devopsschool.com/tutorial/docker/commands/index.html
cp Copy files/folders between a container and the local filesystem
Copy a files/dir from Host machine to Container
Copy a files/dir from Container to Host Machine
21 touch devopsschool.txt
22 ls
23 docker cp devopsschool.txt 7e9cc6153c15:/opt
24 docker exec 7e9cc6153c15 ls /opt
25 ls
26 rm devopsschool.txt
27 lear
28 clear
29 ls
30 docker cp 7e9cc6153c15:/opt/devopsschool.txt
31 docker cp 7e9cc6153c15:/opt/devopsschool.txt .
32 ls
33 clear
34 docker help cp
diff Inspect changes to files or directories on a container's filesystem
ANY CHANGES in the container -
ADDED
EDIT
DELETED
can be seen by Diff commands.
38 docker ps
39 clear
40 docker diff 7e9cc6153c15
41 docker attach 7e9cc6153c15
42 docker ps
43 clear
44 docker diff 7e9cc6153c15
45 history
48 docker inspect 7e9cc6153c15
49 clear
50 docker inspect ubuntu
51 clear
58 docker port 7e9cc6153c15
59 docker run -d jenkins/jenkins
60 docker ps
61 clear
62 docker port 947df6219c13
63 docker stop $(docker ps -a -q)
64 clear
65 docker rm $(docker ps -a -q)
66 clear
67 docker ps
68 docker ps -a
69 docker run -d -p 8080:8080 jenkins/jenkins
70 docker ps
71 docker port 286f30aa6304
72 docker run -d -p 8081:8080 jenkins/jenkins
73 docker port 286f30aa6304
74 docker port 4abf38954908834eb002027c861fb6a54f4c2290ed3da60829608d5ee94275a6
76 clear
77 docker ps
78 docker rename 4abf38954908 dev1
79 docker ps
80 docker run -itd --name dev2 ubuntu
81 docker ps
88 docker stat
89 docker stats
90 docker stats 4e50a711d395
91 docker stats
92 docker help stats
93 docker stats --no-stream
94 clear
95 docker help run
96 clear
97 docker help create
98 clear
105 docker ps
106 docker logs 4e50a711d395
107 docker logs 4abf38954908
108 clear
109 docker ps
110 docker attach 4e50a711d395
111 clear
112 docker ps
113 docker logs 4e50a711d395
115 clear
116 docker ps
117 ps -eaf | grep containerd
118 docker top 4e50a711d395
119 history
docker events
Assignment # docker help
============
update Update configuration of one or more containers
wait Block until one or more containers stop, then print their exit codes
125 docker stop $(docker ps -a -q)
126 docker rm $(docker ps -a -q)
127 clear
128 docker ps
129 docker images
130 docker inspect jenkins/jenkins
131 clear
132 ;ls
133 docker images
134 docker history jenkins/jenkins
135 clear
136 docker run -d jenkins/jenkins
137 docker ps
138 df -kh
139 cd /var/lib/docker/overlay2/01ef6d0be138e34e77da4343c5a5ba1c41e7d73946d832c38c370cb96fb4b260/merged
140 ls
141 docker run -d jenkins/jenkins
142 df -kh
143 clear
144 docker inspect jenkins/jenkins
145 df -kh
146 clear
147 docker ps
148 df -kh
149 docker stop a5ff2f90c497
150 df -kh
151 docker start a5ff2f90c497
152 df -kh
153 docker stop a5ff2f90c497
154 docker start a5ff2f90c497
155 clear
[root@ip-172-31-15-202 docker]# ls -1
buildkit
containers = Meta Data of the container
image = Meta Data of the Image
network = Network Object
overlay2 = This contains all the Data Layers
plugins
runtimes
swarm
tmp
trust
volumes = Volume
[root@ip-172-31-15-202 docker]#
========================================================================
155 clear
156 history
157 docker stop $(docker ps -a -q)
158 clear
159 docker rm $(docker ps -a -q)
160 docker ps -a
161 docker images
162 docker rmi jenkins/jenkins centos ubuntu
163 clear
164 pwd
165 ls
166 docker info
167 clear
168 cd /var/lib/docker
169 clear
170 l
171 ls
172 ls -1
173 clear
174 ls
175 cd overlay2
176 ls
177 du -sh
178 docker pull ubuntu
179 ls
180 docker history ubuntu
181 clear
182 ls
183 docker history ubuntu
184 clear
185 ls
186 du -h --max-depth=0
187 du -kh --max-depth=0
188 du -k --max-depth=0
189 du -h --max-depth=1
190 clear
191 ls
192 cd ./fc8d090434ccc5030c316f19a7755fe1cec9a626e90276451c892edc19b0023d
193 ls
194 cd diff
195 ls
196 cd ../..
197 clear
198 ls
199 docker run -itd ubuntu
200 docker ps
201 df -kh
202 clear
203 ls
204 du -sh fbdf4821baee68ba45e48b7491fa7b4761311eb9e65d930e68b5c11572103d94-init
205 du -sh fbdf4821baee68ba45e48b7491fa7b4761311eb9e65d930e68b5c11572103d94
206 df -kh
207 docker run -itd ubuntu
208 ls
209 clear
210 ls
211 cd b3832b67e18ca6bfac56025810f10446fd88e558267200708d0f4a3bc0c522c8
212 clear
213 ls
214 cd diff
215 ls
216 cd ..
217 ls
218 cd merged/
219 ls
220 df -kh
221 clear
222 ls
223 cd ..
224 ls
225 docker ps
226 docker exec 9b2d4539501b touch /opt/devopsschool.com
227 cd ..
228 ls
229 clear
230 ls
231 find . -name devopsschool.com
232 cd ./b3832b67e18ca6bfac56025810f10446fd88e558267200708d0f4a3bc0c522c8
233 clear
234 lsa
235 ls
236 cd merged
237 clear
238 ls
239 cd opt/
240 ls
241 cd ..
242 cd ..
243 clear
244 ls
245 cd diff/
246 ls
247 cd opt/op
248 cd opt/
249 ls
250 clear
251 ls
252 cd ..
253 ls
254 cd ..
255 ls
256 clear
257 ls
258 docker ps
259 pwd
260 ls
261 docker stop 9b2d4539501b
262 ls
263 docker start 9b2d4539501b
264 ls
265 docker stop 9b2d4539501b
266 ls
267 ls diff/
268 clear
269 ls
270 docker start 9b2d4539501b
271 ls
272 cd merged/opt/
273 ls
274 clear
275 ls
276 cd ..
277 ls
278 cd ..
279 ls
280 cd .
281 cd ..
282 ls
283 history
=========================================================================
- Image contains Multiple file system.
- Each file system is layered over each other so we call it - Layer
- Base layer is Root filesystem and on top of it -- APP and depe lib.
- When you create a container - All layers is getting merged into one Additional layer.
- All layers of Image is Read only. Additional layer is RW.
- All this things is done UNION MOUNTS
- Container Layer is primarily divided into 2
- merged = Containes all layers of the image
- diff = COntains all the changes done in the Container.
- When we stop a container - merged layer get disappeared.
- When we start a container - Layers of image + Diff dir get merged into merged dir.
===================================================================
How to develop a Docker Image?
=================================
Method 1 - Manual Way
- Use "docker commit"
- Require - a Existing Container
- One layer at a time.
Method 2 - CI/CD - Automated way
- Use "docker build"
- Require Dockerfile
- Create multiple layer
What is the requirement?
===========================
Base - ubuntu DONE
---> Update --> GIT --> Apache - COPY index.html
18 docker run -itd ubuntu
19 docker ps
20 ls
21 vi index.html
22 docker ps
23 clear
24 clear
25 ls
26 docker ps
27 docker rename a080b711fdba rajesh2
28 clear
29 docker ps
30 docker attach rajesh2
31 clear
32 docker ps
33 docker attach rajesh2
34 docker cp index.html rajesh2:/var/www/html
35 docker exec rajesh2 more /var/www/html/index.html
36 cleaer
37 clear
38 docker ps
39 docker diff rajesh2
40 clear
41 ls
42 docker ps
43 docker commit -m"up-up-git-ap" -a "Rajesh Kumar" a080b711fdba up-up-git-ap
44 docker images
45 docker history ubuntu
46 docker history up-up-git-ap
47 clear
48 docker ps -a
49 docker stop c9ab7c1f6440 a080b711fdba
50 docker rm c9ab7c1f6440 a080b711fdba
51 docker images
52 docker run -itd --name ubuntu ubuntu
53 docker run -itd --name up-up-git-ap up-up-git-ap
54 docker ps
55 clear
56 docker ps
57 docker exec cca58c3e9f28 git
58 docker exec be901cda0cbf git
59 clear
60 ls
61 docker images
62 history
INSIDE a container
---------
apt-get update
apt-get install git
apt-get install apache2
==========================================================
Dockerfile
===============================================
- Contains
- List of Instructions
- Each line create one layer
- Each Layer get created from the container of Previous line of Dockerfile
FROM ubuntu
MAINTAINER Rajesh Kumar [email protected]
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get -y install tzdata
RUN apt-get install git -y
RUN apt-get install apache2 -y
COPY index.html /var/www/html/
ENV JAVA_HOME=/opt/java
77 docker build -t fromdockerfile .
78 docker images
79 docker rmi 0bf2006cc454
80 docker images
81 docker run -itd fromdockerfile
82 docker ps
83 docker exec b72a85e4e057 env
84 docker exec b72a85e4e057 ls /var/www/html
85 docker exec b72a85e4e057 git
86 clear
87 docker images
88 docker history fromdockerfile
jenkins
openjdk:8-jdk
buildpack-deps:buster-scm
buildpack-deps:buster-curl
debian:buster
scratch
ENTRYPOINT VS CMD
=====================
How to set PID 1?
- ENTRYPOINT
- CMD
ENTRYPOINT VS CMD
----------------------
CMD can be replaced.
ENTRYPOINT can not be replaced.
2 CMD ??
2 ENTRYPOINT ??
1 CMD 1 ENTRYPOINT??
https://www.devopsschool.com/tutorial/docker/dockerfile/dockerfile-example-sample-lab.html