forked from raushan8586/devops-2023-september
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocker-links-commands
424 lines (368 loc) · 10.3 KB
/
Docker-links-commands
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
Installation:
To be a root user -->
sudo su -
1 apt update -y
2 clear
3 apt install docker.io -y
4 docker version
5 docker info
Images:
https://hub.docker.com/
https://hub.docker.com/search?image_filter=official
https://docs.docker.com/
Docker Commands:
https://docs.docker.com/engine/reference/commandline/docker/
Docker Run Command:
https://docs.docker.com/reference/cli/docker/container/run/
Dockerfile --> https://jenkov.com/tutorials/docker/dockerfile.html#entrypoint
https://docs.docker.com/build/building/multi-stage/
*COPY vs ADD, CMD vs ENTRYPOINT
Examples
https://github.com/komljen/dockerfile-examples/tree/master
Docker Network --> https://docs.docker.com/network/drivers/
Docker-Compose --> https://docs.docker.com/compose/samples-for-compose/
https://docs.docker.com/compose/
https://docs.docker.com/compose/intro/history/#compose-file-format-versioning
Resources for a container:
https://stackoverflow.com/questions/42345235/how-to-specify-memory-cpu-limit-in-docker-compose-version-3
All about Docker & Docker-compose-->
https://www.baeldung.com/ops/?s=docker+compose
Docker-compose Restart Policy:
https://www.baeldung.com/ops/docker-compose-restart-policies#:~:text=Restart%20Policy%20in%20Docker%20Compose,yml%20file.
https://docs.docker.com/compose/samples-for-compose/
Installation:
Install latest version of docker-compose: https://github.com/docker/compose/releases/
$ sudo apt remove docker-compose --> optional, in case, you need to remove docker-compose from ubuntu VM
$ wget https://github.com/docker/compose/releases/download/v2.24.1/docker-compose-linux-x86_64
$ chmod +x docker-compose-linux-x86_64
$ sudo mv docker-compose-linux-x86_64 /usr/bin/docker-compose
$ docker-compose --version
Docker Compose version v2.24.1
$ sudo docker-compose up
# Things work
MySQL --> https://www.w3schools.com/MySQL/default.asp
1 apt update -y
2 apt install docker.io -y
3 docker images
4 docker pull httpd
5 docker images
6 apt install apache2 -y
7 systemctl status apache2
8 lsof -i -P -n | grep LISTEN
9 docker images
10 docker inspect httpd
11 docker run -itd -p 82:80 httpd
To name a container
docker run -itd --name intellipaat -p 82:80 httpd
12 docker ps
13 docker container ls
14 lsof -i -P -n | grep LISTEN
15 docker ps
16 docker exec -it 04473fe77015 /bin/bash --> To login (go insider) to the container, updated the package (apt update), install vim (apt install vim), exit (existed the container)
17 docker images
18 docker ps
19 docker commit 04473fe77015 httpd_new --> create the image from container
20 docker images
22 docker pull fedora
23 docker images
24 docker run -itd fedora
25 docker ps
26 docker rename 3f48ad86c7ef My_Fedora
27 docker ps
28 docker exec -it 3f48ad86c7ef /bin/bash
29 docker stats
30 docker container ls
31 docker logs 04473fe77015
32 dcoker images
33 docker images
34 mkdir project1
35 cd project1/
36 touch Dockerfile
-------------------------------
docker volume ls
49 docker volume create intellipaat-volume
50 docker volume ls
51 docker ps
52 docker exec -it 96fa8d4ab869 /bin/bash
53 docker ps
54 docker rm -f 96f
55 docker ps
58 docker volume ls
59 docker run -itd --mount source=intellipaat-volume,target=/usr/local/apache2/htdocs -p 82:80 httpd_new
60 docker ps
61 docker exec -it 721759978adc /bin/bash
62 find / -name intellipaat-volume
63 cd /var/lib/docker/volumes/intellipaat-volume
64 ls -l
65 cd _data/
66 ls -l
67 cat index.html
68 docker exec -it 721759978adc /bin/bash
69 ls -l
70 cat index2.html
71 docker ps
72 docker rm -f 721
73 docker ps
74 ls -l
-------------------------------------------------------
76 ls -l
77 cd /
78 ls -l
79 cd /root
80 ls -l
81 cd project1/
82 ls -l
83 rm Dockerfile
84 ls -l
85 clear
86 ls -l
87 touch Dockerfile
88 vi Dockerfile
89 docker images
90 vi Dockerfile
91 ls -l
92 vi index1.html
93 vi index2.html
94 ls -l
95 docker ps
96 cat Dockerfile
97 docker build . -t httpd1
98 docker images
99 docker run -itd -p 82:80 httpd1
100 cd project1/
101 ls -l
70 docker login
71 docker image tag ubuntu1:latest raushan8586/devops-aug-2024:ubuntu1
72 docker image push raushan8586/devops-aug-2024:ubuntu1
103 cd ..
104 mkdir project2
105 cd project2
106 touch Dockerfile
107 vi Dockerfile
108 vi index1.html
109 ls -l
110 cat Dockerfile
111 docker build . -t ubuntu1
112 docker images
113 docker run -itd -p 82:80 ubuntu1
114 docker ps
115 docker inspect ubuntu1
116 docker ps
117 docker inspect 828cdf681f67
118 cat Dockerfile
119 cd ../project1
120 cay Dockerfile
121 cat Dockerfile '
122 cat Dockerfile
123 docker images
124 find / -name ubuntu1
125 ls -l
126 cd /var/lib/docker/
127 ls -l
128 cd image/
129 ls -l
130 cd overlay2/
131 ls -l
132 cd imagedb/
133 ls -l
134 cd content/
135 ls -l
136 clear
137 cd ~
138 ls -l
139 docker ps
140 docker inspect 828cdf681f67
141 docker network ls
142 docker inspect 469f7f7557be
143 docker inspect 828cdf681f67
144 docker inspect 469f7f7557be
145 docker ps
146 docker inspect 828cdf681f67
147 docker network ls
148 docker inspect 469f7f7557be
150 doccker-compose version
151 docker-compose version
152 apt install docker-compose -y
153 docker-compose version
154 ls -l
155 mkdir project3
156 cd project3
157 docker ps
158 docker rm -f 828
159 docker ps
160 ls -l
161 vi docker-compose.yml
162 cat docker-compose.yml
163 docker-compose up -d
164 lsof -i -P -n | grep LISTEN
165 vi docker-compose.yml
166 docker ps
167 docker-compose down
168 docker-compose up -d
169 docker ps
170 docker volume ls
171 docker network ls
182 docker-compose up -d
183 docker ps
184 cat docker-compose.yml
185 docker ps
186 docker exec -it 824329e8f770 /bin/bash
187 docker ps
188 docker exec -it 4b63a2f753ed /bin/bash --> mysql -u wordpress -p wordpress (connect to mysql db client/instance using this)
189 docker ps
190 docker images
191 docker image tag httpd1:latest raushan8586/devops-september-2023:httpd1
192 docker login
193 docker image push raushan8586/devops-september-2023:httpd1
----------------------------------------------------------------------------------
17th Jan 2024
root@ip-172-31-38-64:~# history
1 uname -a
2 apt update -y
3 clear
4 docker version
5 apt install docker.io -y
6 clear
7 docker version
8 history
9 git version
10 docker version
11 clear
12 docker images
13 apt install apache2 -y
14 lsod -i -P -n | grep LISTEN
15 lsof -i -P -n | grep LISTEN
16 docker pull httpd
17 docker images
18 docker ps
19 docker inspect httpd
20 clear
21 dcoker images
22 clear
23 docker images
24 docker run -itd -p 82:80 httpd
25 docker ps
26 docker exec -it 221cc6440498 /bin/bash
Navigate to /usr/local/apache2/htdocs in the container to fidn index.html
18th Jan 2024
root@ip-172-31-0-64:~# history
sudo su -
1 apt update -y
2 apt install docker.io -y
3 docker run -itd -p 82:80 httpd
4 docker network ls
5 clear
6 docker-compose version
7 apt install docker-compose -y
8 vi docker-compose.yaml
9 docker ps
10 docker rm -f 47b2d18f5d96
11 docker ps
12 clear
13 ls -l
14 docker-compose up -d
15 docker ps
16 docker exec -it 7863766b4023 /bin/bash
mysql container --> cd /var/lib/mysql --> mysql -u wordpress -p wordpress
show databases;
use <database>;
show tables;
select * from <table>;
17 exit
18 docker ps
19 docker-compose down
20 docker-compose up -d
21 docker volume la
22 docker volume ls
23 docker netowrk ls
24 docker network ls
25 ls -l
26 history
29 docker images
30 docker image tag wordpress:latest raushan8586/devops-jan-2024:wordpress
31 docker image push raushan8586/devops-jan-2024:wordpress
docker logs fd0ac55645a0
41 clear
42 docker ps
43 docker logs 95f620e1df7c
24th May
------------
364 lsof -i -P -n | grep LISTEN
365 apt update -y
366 clear
367 apt install apache2 -y
368 lsof -i -P -n | grep LISTEN
369 cat /var/www/html/
370 cd /var/www/html/
371 ls -l
372 vi raushan-page.html
373 docker version
374 apt install docker.io -y
375 clear
376 docker version
30th May
---------
104 docker version
105 docker volume ls
106 docker volume create demo-vol
107 docker volume ls
108 cd /var/lib/docker/volumes/
109 ls -l
110 pwd
111 df -h
112 cd ~
113 clear
114 docker ps
115 docker run -itd --mount source=demo-vol,target=/usr/local/apache2/htdocs --name web-cont -p 82:80 httpd
116 docker ps
117 docker volume ls
118 cd /var/lib/docker/volumes/demo-vol/_data/
119 ls -l
120 cat index.html
121 vi index1.html
122 ls -l
123 docker run -itd --mount source=demo-vol,target=/usr/local/apache2/htdocs --name web-cont2 -p 83:80 httpd
124 docker ps
125 docker rm -f 200eab649f4c
126 docker ps
127 cd ~
128 docker images
-----------------------------
140 docker-compose version
141 apt update -y
142 ls -l
143 mkdir project1
144 cd project1/
145 vi docker-compose.yaml
146 docker-compose version
147 wget https://github.com/docker/compose/releases/download/v2.24.1/docker-compose-linux-x86_64
148 ls -l
149 chmod +x docker-compose-linux-x86_64
150 sudo mv docker-compose-linux-x86_64 /usr/bin/docker-compose
151 docker-compose version
152 ls -l
153 clear
154 ls -l
155 docker-compose up -d
156 docker network ls
157 docker volume ls
158 docker ps
159 docker images
160 docker inspect wordpress
161 docker ps
162 docker exec -it 7944f87348b4 /bin/bash
163 docker ps
164 docker exec -it b70564da64b3 /bin/bash
165 docker ps
166 clear
167 docker ps
168 docker logs 7944f87348b4
169 docker ps
170 clear
171 docker ps
172 docker logs b70564da64b3
173 docker ps
174 docker-compose down
175 docker ps
176 docker-compose up -d
177 docker ps