chrisluiz16

Day 5

May 25th, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 15.33 KB | None | 0 0
  1.  
  2.  
  3. #---------------------------------------------------- httpd image pull --------------------------------------------#
  4.  
  5.  
  6. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image pull httpd:alpine
  7. alpine: Pulling from library/httpd
  8. 8a49fdb3b6a5: Already exists
  9. beb66a906b34: Already exists
  10. 01924573e8db: Already exists
  11. 255f194b76b3: Already exists
  12. 0f48f8ea2bc9: Already exists
  13. 390cbd08c8ae: Already exists
  14. Digest: sha256:3e25d419bf180122f5f9af5cf2180709d8234320ff25514a61f5d1bc3cf46394
  15. Status: Downloaded newer image for httpd:alpine
  16. docker.io/library/httpd:alpine
  17.  
  18. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  19. REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
  20. httpd        alpine    d7544b312621   13 days ago   59.1MB
  21.  
  22. [ec2-user@ip-172-31-41-59 docker-pull]$ docker container run --name test -d httpd:alpine
  23. afeaa05d87dcd717170052185601280201ab00d38fe9c86d301fe026d06ee19c
  24. [ec2-user@ip-172-31-41-59 docker-pull]$
  25. [ec2-user@ip-172-31-41-59 docker-pull]$
  26. [ec2-user@ip-172-31-41-59 docker-pull]$ docker container cp test:/usr/local/apache2/conf/httpd.conf .
  27. [ec2-user@ip-172-31-41-59 docker-pull]$
  28. [ec2-user@ip-172-31-41-59 docker-pull]$ ls
  29. httpd.conf  site1
  30.  
  31. #---------------------------------------------------- Image Creation --------------------------------------------#
  32.  
  33.  
  34. [ec2-user@ip-172-31-41-59 docker-pull]$ cat Dockerfile
  35. FROM httpd:alpine
  36. COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf
  37. COPY ./site1/ /usr/local/apache2/htdocs/
  38. CMD ["httpd-foreground"]
  39.  
  40.  
  41. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image build -t productionapp:1 .
  42. Sending build context to Docker daemon  2.529MB
  43. Step 1/4 : FROM httpd:alpine
  44.  ---> d7544b312621
  45. Step 2/4 : COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf
  46.  ---> 719c2d98bd10
  47. Step 3/4 : COPY ./site1/ /usr/local/apache2/htdocs/
  48.  ---> 6434da0e48be
  49. Step 4/4 : CMD ["httpd-foreground"]
  50.  ---> Running in 35c3ecc051bc
  51. Removing intermediate container 35c3ecc051bc
  52.  ---> 7ac4702dd0e4
  53. Successfully built 7ac4702dd0e4
  54. Successfully tagged productionapp:1
  55.  
  56.  
  57. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  58. REPOSITORY      TAG       IMAGE ID       CREATED          SIZE
  59. productionapp   1         7ac4702dd0e4  10 seconds ago   61.6MB
  60. httpd           alpine    d7544b312621   13 days ago      59.1MB
  61.  
  62.  
  63.  
  64. #---------------------------------------------------- Image pull --------------------------------------------#
  65.  
  66.  
  67.  
  68. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image tag productionapp:1 chrisluiz16/productionapp:1
  69. [ec2-user@ip-172-31-41-59 docker-pull]$
  70. [ec2-user@ip-172-31-41-59 docker-pull]$
  71. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image push chrisluiz16/productionapp:1
  72. The push refers to repository [docker.io/chrisluiz16/productionapp]
  73. 6f49d5628596: Pushed
  74. 9f55559c2658: Pushed
  75.  
  76. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image push chrisluiz16/productionapp:latest
  77.  
  78. [ec2-user@ip-172-31-41-59 docker-pull]$
  79. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  80. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  81. chrisluiz16/productionapp   1         7ac4702dd0e4   11 minutes ago   61.6MB
  82. productionapp               1         7ac4702dd0e4   7 minutes ago        61.6MB
  83. httpd                       alpine    d7544b312621   13 days ago      59.1MB
  84. [ec2-user@ip-172-31-41-59 docker-pull]$
  85. [ec2-user@ip-172-31-41-59 docker-pull]$
  86. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image tag chrisluiz16/productionapp:1 chrisluiz16/productionapp:latest
  87. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  88. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  89. chrisluiz16/productionapp   1         7ac4702dd0e4   7 minutes ago        61.6MB
  90. chrisluiz16/productionapp   latest    7ac4702dd0e4   7 minutes ago        61.6MB
  91. productionapp               1         7ac4702dd0e4   7 minutes ago        61.6MB
  92. httpd                       alpine    d7544b312621   13 days ago      59.1MB
  93.  
  94.  
  95. #---------------------------------------------------- Client machine container creation --------------------------------------------#
  96.  
  97.  
  98. [ec2-user@client-machine ~]$ docker image pull chrisluiz16/productionapp
  99. Using default tag: latest
  100. Status: Downloaded newer image for chrisluiz16/productionapp:latest
  101. docker.io/chrisluiz16/productionapp:latest
  102. [ec2-user@client-machine ~]$
  103. [ec2-user@client-machine ~]$
  104. [ec2-user@client-machine ~]$ docker image ls
  105. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  106. chrisluiz16/productionapp   latest    7ac4702dd0e4   11 minutes ago   61.6MB
  107. [ec2-user@client-machine ~]$
  108. [ec2-user@client-machine ~]$
  109. [ec2-user@client-machine ~]$ docker container run --name webserver1 -d -p 8081:80 chrisluiz16/productionapp
  110. b5f942cae5ef439b9a444539aab6407516aa47afad65b8574a94959ea84ac1e6
  111.  
  112.  
  113. #---------------------------------------------------- Version 2 --------------------------------------------#
  114.  
  115. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image build -t chrisluiz16/productionapp:2 .
  116. Sending build context to Docker daemon  2.529MB
  117.  ---> 12c6e3622630
  118. Successfully built 12c6e3622630
  119. Successfully tagged chrisluiz16/productionapp:2
  120.  
  121. [ec2-user@ip-172-31-41-59 docker-pull]$
  122. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  123. REPOSITORY                  TAG       IMAGE ID       CREATED              SIZE
  124. chrisluiz16/productionapp   2         12c6e3622630   About a minute ago   61.6MB
  125. chrisluiz16/productionapp   1         7ac4702dd0e4   7 minutes ago        61.6MB
  126. chrisluiz16/productionapp   latest    7ac4702dd0e4   7 minutes ago        61.6MB
  127. productionapp               1         7ac4702dd0e4   7 minutes ago        61.6MB
  128. httpd                       alpine    d7544b312621   13 days ago          59.1MB
  129.  
  130. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image tag chrisluiz16/productionapp:2 chrisluiz16/productionapp:latest
  131. [ec2-user@ip-172-31-41-59 docker-pull]$
  132. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  133. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  134. chrisluiz16/productionapp   2         12c6e3622630   7 minutes ago    61.6MB
  135. chrisluiz16/productionapp   latest    12c6e3622630   7 minutes ago    61.6MB
  136. chrisluiz16/productionapp   1         7ac4702dd0e4   14 minutes ago   61.6MB
  137. productionapp               1         7ac4702dd0e4   14 minutes ago   61.6MB
  138. httpd                       alpine    d7544b312621   13 days ago      59.1MB
  139.  
  140. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image push chrisluiz16/productionapp:2
  141. The push refers to repository [docker.io/chrisluiz16/productionapp]
  142. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image push chrisluiz16/productionapp:latest
  143. The push refers to repository [docker.io/chrisluiz16/productionapp]
  144.  
  145.  
  146. #----
  147. ------------------------------------------------ Client machine container creation Version2 --------------------------------------------#
  148.  
  149. ec2-user@client-machine ~]$ docker image pull chrisluiz16/productionapp
  150. Using default tag: latest
  151. latest: Pulling from chrisluiz16/productionapp
  152. 8a49fdb3b6a5: Already exists
  153. beb66a906b34: Already exists
  154. 01924573e8db: Already exists
  155. 255f194b76b3: Already exists
  156. 0f48f8ea2bc9: Already exists
  157. 390cbd08c8ae: Already exists
  158. 87af820e40d5: Already exists
  159. 6cba2c7aef59: Pull complete
  160. Digest: sha256:16b22770777ecde8a0621bf1794a9c6a20d75ad2cc17cccf323bc4920e5af46b
  161. Status: Downloaded newer image for chrisluiz16/productionapp:latest
  162. docker.io/chrisluiz16/productionapp:latest
  163. [ec2-user@client-machine ~]$ docker image ls
  164. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  165. chrisluiz16/productionapp   latest    12c6e3622630   12 minutes ago   61.6MB
  166. chrisluiz16/productionapp   <none>    7ac4702dd0e4   19 minutes ago   61.6MB
  167.  
  168. [ec2-user@client-machine ~]$ docker container run --name webserver2 -d -p 8082:80 chrisluiz16/productionapp
  169. 818bc7afa64cfbbf2a2682aa1a7810bba71f1a81ab0822adf7caf4b911d51c4c
  170.  
  171. [ec2-user@client-machine ~]$ docker container ls -a
  172. CONTAINER ID   IMAGE                       COMMAND              CREATED          STATUS          PORTS                                   NAMES
  173. 818bc7afa64c   chrisluiz16/productionapp   "httpd-foreground"   20 seconds ago   Up 19 seconds   0.0.0.0:8082->80/tcp, :::8082->80/tcp   webserver2
  174. 047eabd99890   7ac4702dd0e4                "httpd-foreground"   18 minutes ago   Up 18 minutes   0.0.0.0:8081->80/tcp, :::8081->80/tcp   webserver1
  175.  
  176.  
  177.  
  178. #---------------------------------------------------- Version 3--------------------------------------------#
  179.  
  180. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image build -t chrisluiz16/productionapp:3 .
  181. Sending build context to Docker daemon  2.529MB
  182. Step 1/4 : FROM httpd:alpine
  183.  ---> d7544b312621
  184. Step 2/4 : COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf
  185.  ---> Using cache
  186.  ---> 2c37b84dda20
  187. Step 3/4 : COPY ./site1/ /usr/local/apache2/htdocs/
  188.  ---> 31e3de60907e
  189. Step 4/4 : CMD ["httpd-foreground"]
  190.  ---> Running in b6e489a7c888
  191. Removing intermediate container b6e489a7c888
  192.  ---> 49a9519e8e6c
  193. Successfully built 49a9519e8e6c
  194. Successfully tagged chrisluiz16/productionapp:3
  195.  
  196. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image tag chrisluiz16/productionapp:3 chrisluiz16/productionapp:latest
  197. [ec2-user@ip-172-31-41-59 docker-pull]$
  198. [ec2-user@ip-172-31-41-59 docker-pull]$
  199. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  200. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  201. chrisluiz16/productionapp   3         49a9519e8e6c   31 seconds ago   61.6MB
  202. chrisluiz16/productionapp   latest    49a9519e8e6c   31 seconds ago   61.6MB
  203. chrisluiz16/productionapp   2         12c6e3622630   17 minutes ago   61.6MB
  204. chrisluiz16/productionapp   1         7ac4702dd0e4   24 minutes ago   61.6MB
  205. productionapp               1         7ac4702dd0e4   24 minutes ago   61.6MB
  206. httpd                       alpine    d7544b312621   13 days ago      59.1MB
  207. [ec2-user@ip-172-31-41-59 docker-pull]$
  208. [ec2-user@ip-172-31-41-59 docker-pull]$
  209. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image push chrisluiz16/productionapp:3
  210. The push refers to repository [docker.io/chrisluiz16/productionapp]
  211. 124944b64f57: Pushed
  212. 06515172d06a: Layer already exists
  213. a98c0c13236c: Layer already exists
  214. 9e2cb215930a: Layer already exists
  215. 62b03e3606b9: Layer already exists
  216. 8d783d71838c: Layer already exists
  217. 1f6500633a39: Layer already exists
  218. bb01bd7e32b5: Layer already exists
  219. 3: digest: sha256:c6d6835c12ce9ead3720ee95f047fd6335e8dadd407267fd4ac4c11e5cea385f size: 1991
  220. [ec2-user@ip-172-31-41-59 docker-pull]$
  221. [ec2-user@ip-172-31-41-59 docker-pull]$
  222. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image push chrisluiz16/productionapp:latest
  223. The push refers to repository [docker.io/chrisluiz16/productionapp]
  224. 124944b64f57: Layer already exists
  225. 06515172d06a: Layer already exists
  226. a98c0c13236c: Layer already exists
  227. 9e2cb215930a: Layer already exists
  228. 62b03e3606b9: Layer already exists
  229. 8d783d71838c: Layer already exists
  230. 1f6500633a39: Layer already exists
  231. bb01bd7e32b5: Layer already exists
  232. latest: digest: sha256:c6d6835c12ce9ead3720ee95f047fd6335e8dadd407267fd4ac4c11e5cea385f size: 1991
  233. [ec2-user@ip-172-31-41-59 docker-pull]$
  234. [ec2-user@ip-172-31-41-59 docker-pull]$
  235. [ec2-user@ip-172-31-41-59 docker-pull]$ docker image ls
  236. REPOSITORY                  TAG       IMAGE ID       CREATED              SIZE
  237. chrisluiz16/productionapp   3         49a9519e8e6c   About a minute ago   61.6MB
  238. chrisluiz16/productionapp   latest    49a9519e8e6c   About a minute ago   61.6MB
  239. chrisluiz16/productionapp   2         12c6e3622630   18 minutes ago       61.6MB
  240. chrisluiz16/productionapp   1         7ac4702dd0e4   25 minutes ago       61.6MB
  241. productionapp               1         7ac4702dd0e4   25 minutes ago       61.6MB
  242. httpd                       alpine    d7544b312621   13 days ago          59.1MB
  243.  
  244.  
  245.  
  246. #---------------------------------------------------- Client machine container creation Version3 --------------------------------------------#
  247.  
  248.  
  249. [ec2-user@client-machine ~]$ docker image pull chrisluiz16/productionapp
  250. Using default tag: latest
  251. latest: Pulling from chrisluiz16/productionapp
  252. 8a49fdb3b6a5: Already exists
  253. beb66a906b34: Already exists
  254. 01924573e8db: Already exists
  255. 255f194b76b3: Already exists
  256. 0f48f8ea2bc9: Already exists
  257. 390cbd08c8ae: Already exists
  258. 87af820e40d5: Already exists
  259. 00328d0116e0: Pull complete
  260. Digest: sha256:c6d6835c12ce9ead3720ee95f047fd6335e8dadd407267fd4ac4c11e5cea385f
  261. Status: Downloaded newer image for chrisluiz16/productionapp:latest
  262. docker.io/chrisluiz16/productionapp:latest
  263. [ec2-user@client-machine ~]$
  264. [ec2-user@client-machine ~]$
  265. [ec2-user@client-machine ~]$ docker image ls
  266. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  267. chrisluiz16/productionapp   latest    49a9519e8e6c   2 minutes ago    61.6MB
  268. chrisluiz16/productionapp   <none>    12c6e3622630   19 minutes ago   61.6MB
  269. chrisluiz16/productionapp   <none>    7ac4702dd0e4   26 minutes ago   61.6MB
  270.  
  271. [ec2-user@client-machine ~]$ docker container run --name webserver3 -d -p 8083:80 chrisluiz16/productionapp
  272. 81ba7d219a5c73def357ccbe8443e4ee65a30c26ce7578798b3c9927bda1c305
  273. [ec2-user@client-machine ~]$
  274. [ec2-user@client-machine ~]$ docker container ls -a
  275. CONTAINER ID   IMAGE                       COMMAND              CREATED          STATUS          PORTS                                   NAMES
  276. 81ba7d219a5c   chrisluiz16/productionapp   "httpd-foreground"   30 seconds ago   Up 28 seconds   0.0.0.0:8083->80/tcp, :::8083->80/tcp   webserver3
  277. 818bc7afa64c   12c6e3622630                "httpd-foreground"   7 minutes ago    Up 7 minutes    0.0.0.0:8082->80/tcp, :::8082->80/tcp   webserver2
  278. 047eabd99890   7ac4702dd0e4                "httpd-foreground"   26 minutes ago   Up 26 minutes   0.0.0.0:8081->80/tcp, :::8081->80/tcp   webserver1
  279. [ec2-user@client-machine ~]$
  280.  
  281.  
  282.  
  283. #---------------------------------------------------- Removing all Dangling image --------------------------------------------#
  284.  
  285.  
  286. [ec2-user@client-machine ~]$ docker image ls -a
  287. REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
  288. chrisluiz16/productionapp   latest    49a9519e8e6c   8 minutes ago    61.6MB
  289. chrisluiz16/productionapp   <none>    12c6e3622630   25 minutes ago   61.6MB
  290. chrisluiz16/productionapp   <none>    7ac4702dd0e4   31 minutes ago   61.6MB
  291. [ec2-user@client-machine ~]$
  292. [ec2-user@client-machine ~]$
  293. [ec2-user@client-machine ~]$ docker container stop webserver1 webserver2
  294. webserver1
  295. webserver2
  296. [ec2-user@client-machine ~]$ docker container rm webserver1 webserver2
  297. webserver1
  298. webserver2
  299. [ec2-user@client-machine ~]$ docker image prune
  300. WARNING! This will remove all dangling images.
  301. Are you sure you want to continue? [y/N] y
  302. Deleted Images:
  303. untagged: chrisluiz16/productionapp@sha256:d6abbc2d051659d7c0e01d5d387b8b9951cb9b81e795d79778e6ae4fa56f8df1
  304. deleted: sha256:7ac4702dd0e4aa5d9f3be28d48044b40740a634ea37216b880af0ccb29cc7709
  305. deleted: sha256:c8d29022145b067324f2e581ce42264bb57c6f65d272e7148ad6f8aa0d5e346b
  306. untagged: chrisluiz16/productionapp@sha256:16b22770777ecde8a0621bf1794a9c6a20d75ad2cc17cccf323bc4920e5af46b
  307. deleted: sha256:12c6e3622630c8ee9a83cd5e90711591a680d7b5754f0bd66ff82f66b5ed035b
  308. deleted: sha256:9392e80e1ab3e875b728b0ed09f1fb485f2bdc0f453184256928350b4f3a06c8
  309.  
  310. Total reclaimed space: 4.961MB
  311. [ec2-user@client-machine ~]$ docker image ls -a
  312. REPOSITORY                  TAG       IMAGE ID       CREATED         SIZE
  313. chrisluiz16/productionapp   latest    49a9519e8e6c   9 minutes ago   61.6MB
  314. [ec2-user@client-machine ~]$
Advertisement
Add Comment
Please, Sign In to add comment