๐ ์์ฝ
์ปดํจํฐ๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ์ต์ด ์๋์ฐ๋ฅผ ์ค์นํด์ผ ์ฌ์ฉํ ์ ์์.
์๋์ฐ ํ๋ก๊ทธ๋จ์ OS(Operating System) ๋ผ๊ณ ํ๊ณ ์ด์์ฒด์ ๋ผ๊ณ ํจ.
์ด์์ฒด์ ๋ ํค๋ณด๋, ๋ง์ฐ์ค, ์์
, ๋์์ ๋ฑ์ ํ๊ฒฝ์ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์๊ฒ ํด์ฃผ๋ S/W ๋ก ์ต์ด๋ก ์ค์น๋์ด์ผ ํจ.
์ด์์ฒด์ ์ ์ข
๋ฅ๋ ์๋์ฐ(Window), ๋ฆฌ๋
์ค(Linux), ์ ๋์ค(Unix)๊ฐ ์์ผ๋ฉฐ ์ฃผ๋ก ๊ฐ์ธ์ฉ์ผ๋ก ์๋์ฐ๋ฅผ ์ฌ์ฉํ๊ณ ํ์ฌ์์๋ ๋ฆฌ๋
์ค ๋๋ ์ ๋์ค๊ฐ ์ฌ์ฉ๋จ
์์ ๊ธฐ์ :
– Basic : ๋ฆฌ๋ ์ค
๐ ๊ธฐ์ ๊ตฌํ
์คํ :
- docker desktop
๐ ์ปจํ ์ด๋
1) ์ปจํ ์ด๋ ์ฒซ๊ฑธ์
์ปจํ ์ด๋ : ์ด๋ฏธ์ง(s/w ์ผ์ข ),
์ปจํ ์ด๋(์คํ๋ s/w)
์ปจํ ์ด๋ ๊ฐ์ ๋ ๋ฆฝ๋ ๊ณต๊ฐ์์ ํ๋ํจ
2) ๋์ปค์์ hello-world ์ด๋ฏธ์ง ์คํํ๊ธฐ
์ฌ์ฉ๋ฒ) docker run hello-world
— ์ด๋ฏธ์ง ๋ค์ด๋ก๋ ์์
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 719385e32844: Pull complete Digest: sha256:fc6cf906cbfa013e80938cdf0bb199fbdbb86d6e3e013783e5a766f50f5dbce0 Status: Downloaded newer image for hello-world:latest
— ์ด๋ฏธ์ง ๋ค์ด๋ก๋ ๋
— ์ด๋ฏธ์ง ์คํ
Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
3) ์ด๋ฏธ์ง ๋ค์ด๋ก๋ :
ํ๊ทธ ์๋ต : ์ต์ ๋ฒ์ (latest)
์ฌ์ฉ๋ฒ) docker pull ์ด๋ฏธ์ง๋ช :ํ๊ทธ
๋ฆฌ๋ ์ค : ๋ฌด๋ฃ(ubuntu), ์์ฉ(redhat), ๋ฌด๋ฃ(centos:7)
docker pull centos:7
C:\Users2>docker pull centos:7 7: Pulling from library/centos 2d473b07cdd5: Pull complete Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Status: Downloaded newer image for centos:7 docker.io/library/centos:7
๋ค์ด๋ก๋๋ ์ด๋ฏธ์ง ๋ณด๊ธฐ ๋ช ๋ น์ด
์ฌ์ฉ๋ฒ) docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB centos 7 eeb6ee3f44bd 20 months ago 204MB
์ปจํ ์ด๋ ์คํ : docker run
4) centos:7 ์ ์คํํด ๋ณด์ธ์
์ฌ์ฉ๋ฒ) docker run -it –name test1 centos:7 bash
docker run : ์ปจํ ์ด๋ ์คํ ๋ช ๋ น
-d : daemon(์จ๊ฒจ์ ธ์ ์คํ๋๋ ํ๋ก๊ทธ๋จ), ๋ฐฑ๊ทธ๋ผ์ด ํ๋ก์ธ์ค
-it : ํฐ๋ฏธ๋๋ก ์ ์ํด์ ๋ช ๋ น์ด๋ฅผ ์คํํ๋ ํ๊ฒฝ์ ๋์ฐ์์ ๋ผ๋ ์ต์
–name ๋ณ๋ช : ์ปจํ ์ด๋ ๋ณ๋ช ๋ถ์ด๊ธฐ ์ต์
centos:7 : ์ด๋ฏธ์ง๋ช
bash : ์ฌ์ฉํ ์ ํ๊ฒฝ(์: bash, sh ๋ฑ)
C:\Users2>docker run -it --name test1 centos:7 bash [root@98e0aa051537 /]# ls anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@98e0aa051537 /]# exit C:\Users2>
์ปจํ ์ด๋ ์ํ ๋ณด๊ธฐ(๋ชฉ๋ก๋ณด๊ธฐ) : docker ps
์คํ์ค์ธ ์ปจํ ์ด๋ ๋ชฉ๋ก์ ์ถ๋ ฅ
์ฌ์ฉ๋ฒ) docker ps
-a : ์คํ/์ค์ง ๋ชจ๋ ์ปจํ ์ด๋ ๋ชฉ๋ก ๋ณด๊ธฐ
5) ํ์ฌ ์คํ์ค์ธ ์ปจํ ์ด๋ ๋ชฉ๋ก์ ํ๋ฉด์ ์ถ๋ ฅ
C:\Users2>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
์ ์ฒด(์คํ/์ค์ง) ์ปจํ ์ด๋ ๋ณด๊ธฐ
์ฌ์ฉ๋ฒ) docker ps -a
C:\Users2>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 98e0aa051537 centos:7 "bash" 24 minutes ago Exited (0) 20 minutes ago test1 89b7101f0b41 hello-world "/hello" 39 minutes ago Exited (0) 39 minutes ago sweet_jang
์ปจํ ์ด๋ ๋ก๊ทธ ์ถ๋ ฅ : docker logs
6) hello-world ์ปจํ ์ด๋ ๋ก๊ทธ๋ฅผ ์ถ๋ ฅํ์ธ์
์ฌ์ฉ๋ฒ) docker logs ์ปจํ ์ด๋๋ช (์ปจํ ์ด๋id, ๋ณ๋ช )
docker logs 89b7101f0b41
C:\Users2>docker logs 89b7101f0b41 Hello from Docker! This message shows that your installation appears to be working correctly. ...์๋ต
์ปจํ ์ด๋ ์ฌ๊ธฐ๋ : docker start
์ฌ์ฉ๋ฒ) docker start ์ปจํ ์ด๋๋ช (์ปจํ ์ด๋id, ๋ณ๋ช )
7) centos:7 ๋ฅผ ๋ค์ ์ฌ์คํ ์ํค์ธ์
docker start test1
C:\Users2>docker start test1 test1
์คํ๋ ์ปจํ ์ด๋ ๋ณด๊ธฐ
docker ps
C:\Users2>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 98e0aa051537 centos:7 "bash" 35 minutes ago Up 15 seconds test1
์ปจํ ์ด๋์ ์ ์ํ๊ธฐ(์คํ๋ ์ปจํ ์ด๋๋ง ๊ฐ๋ฅ)
์ฌ์ฉ๋ฒ) docker attach ์ปจํ ์ด๋๋ช (์ปจํ ์ด๋id, ๋ณ๋ช )
C:\Users2>docker attach test1 [root@98e0aa051537 /]#
8) ubuntu:latest ๋ฆฌ๋ ์ค ์ด๋ฏธ์ง๋ฅผ ๋ค์ด๋ก๋ ๋ฐ๊ณ ์ปจํ ์ด๋์ ์ ์์ ๋ณด์ธ์
ํํธ) docker pull, images, run
(1) ubuntu ์ด๋ฏธ์ง ๋ค์ด๋ก๋
docker pull ubuntu
C:\Users2>docker pull ubuntu Using default tag: latest latest: Pulling from library/ubuntu 837dd4791cdc: Pull complete Digest: sha256:ac58ff7fe25edc58bdf0067ca99df00014dbd032e2246d30a722fa348fd799a5 Status: Downloaded newer image for ubuntu:latest docker.io/library/ubuntu:latest
9) (2) ์ด๋ฏธ์ง ๋ชฉ๋ก ๋ณด๊ธฐ
docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB centos 7 eeb6ee3f44bd 20 months ago 204MB C:\Users2>
10) ubuntu ์ปจํ ์ด๋ ์คํ
docker run -it –name ubuntu ubuntu bash
C:\Users2>docker run -it --name ubuntu ubuntu bash root@ccf0e618b725:/#
์ปจํ ์ด๋ ์ค์ง
11) ์์ ์ฐ์ต๋ฌธ์ ubuntu ์ ๋ค๋ฅธ ํฐ๋ฏธ๋๋ฅผ ์ด๊ณ ์ผ๋ฐ ์ ์งํด๋ณด์ธ์
์ฌ์ฉ๋ฒ) docker stop ์ปจํ ์ด๋๋ช (์ปจํ ์ด๋id, ๋ณ๋ช )
C:\Users2>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ccf0e618b725 ubuntu "bash" 3 minutes ago Up 3 minutes ubuntu C:\Users2>docker stop ubuntu ubuntu
12) ๋ค์ ubuntu ๋ฅผ ์ ์ํ ์ํ์์ ๋ค๋ฅธ ํฐ๋ฏธ๋์์ ๊ฐ์ ์ข ๋ฃํด ๋ณด์ธ์
C:\Users2>docker kill ubuntu ubuntu C:\Users2>
์ด๋ฏธ์ง๋ฅผ ์๊ฒฉ ๋ ํฌ์งํ ๋ฆฌ(๋์ปคํ๋ธ)์ ๋ณด๊ด(์ ๋ก๋)
1) docker login : ๋์ปคํ๋ธ ๊ฐ์ (๊ณ์ , ์ํธ)
2) docker push : ์ ๋ก๋ ๋ช ๋ น์ด
13) ubuntu ์ด๋ฏธ์ง๋ฅผ ์์ ์ ๋์ปคํ๋ธ์ ์ ๋ก๋ ํ์ธ์
(1) docker login
C:\Users2>docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: kangtaegyung Password: WARNING! Your password will be stored unencrypted in C:\Users2\.docker\config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded C:\Users2>
(2) docker push
์ฌ๋ฆฐ ์ด๋ฏธ์ง๋ช : ๊ณ์ ๋ช /์ด๋ฏธ์ง๋ช :ํ๊ทธ
์) kangtaegyung/ubuntu
์ฌ๋ฆด ์ด๋ฏธ์ง๋ช ์ ์(ํ๊ทธ)
์ฌ์ฉ๋ฒ) docker tag ์ด๋ฏธ์ง๋ช ๊ณ์ ๋ช /์ด๋ฏธ์ง๋ช :ํ๊ทธ
๋์ปค ์ด๋ฏธ์ง ๋ชฉ๋ก ๋ณด๊ธฐ
docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB centos 7 eeb6ee3f44bd 20 months ago 204MB
๋์ปค ์ด๋ฏธ์ง ์ถ๊ฐ(ํ๊ทธ ๋ถ์ด๊ธฐ)
docker tag ubuntu kangtaegyung/ubuntu
C:\Users2>docker tag ubuntu kangtaegyung/ubuntu
๋์ปค ์ด๋ฏธ์ง ๋ชฉ๋ก ๋ค์ ๋ณด๊ธฐ
docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB kangtaegyung/ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB centos 7 eeb6ee3f44bd 20 months ago 204MB C:\Users2>
๋์ปค ์ด๋ฏธ์ง ์ ๋ก๋(push)
์ฌ์ฉ๋ฒ) docker push ๊ณ์ ๋ช /์ด๋ฏธ์ง๋ช :ํ๊ทธ
docker push kangtaegyung/ubuntu
C:\Users2>docker push kangtaegyung/ubuntu The push refers to repository [docker.io/kangtaegyung/ubuntu] 966e94ab6e16: Mounted from library/ubuntu latest: digest: sha256:65994a6106186040e20fff871f53e5cb623193705fb4c93d8b9be01fc3aaaebf size: 529 C:\Users2>
์ปจํ ์ด๋ ์ญ์ : docker rm
์ฌ์ฉ๋ฒ) docker rm ์ปจํ ์ด๋๋ช (์ปจํ ์ด๋id, ๋ณ๋ช )
14) centos:7 ์ปจํ ์ด๋ ์ญ์ ํด ์ฃผ์ธ์
(1) ์ปจํ ์ด๋ ์ ์ฒด ๋ชฉ๋ก
docker ps -a
C:\Users2>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ccf0e618b725 ubuntu "bash" About an hour ago Exited (137) 56 minutes ago ubuntu 98e0aa051537 centos:7 "bash" 2 hours ago Exited (0) About an hour ago test1 89b7101f0b41 hello-world "/hello" 2 hours ago Exited (0) 2 hours ago sweet_jang
15) ์ปจํ ์ด๋ ์ญ์
docker rm test1
C:\Users2>docker rm test1 test1
๋ค์ ๋์ปค ์ ์ฒด ๋ชฉ๋ก ๋ณด๊ธฐ
docker ps -a
C:\Users2>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ccf0e618b725 ubuntu "bash" About an hour ago Exited (137) 57 minutes ago ubuntu 89b7101f0b41 hello-world "/hello" 2 hours ago Exited (0) 2 hours ago sweet_jang
16) centos:7 ๋ค์ด๋ก๋ ๋ฐ์ ์ด๋ฏธ์ง๋ฅผ ์ญ์ ํด ์ฃผ์ธ์
์ฌ์ฉ๋ฒ) docker rmi ์ด๋ฏธ์ง๋ช :ํ๊ทธ(์ด๋ฏธ์งid)
์ฐธ๊ณ ) ์ด๋ฏธ์ง ์ญ์ ์ ๋ฏธ๋ฆฌ ์ปจํ ์ด๋๊ฐ ์ญ์ ๋์ด ์์ด์ผํจ
(1) ์ด๋ฏธ์ง ์ ์ฒด ๋ชฉ๋ก
docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE kangtaegyung/ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB centos 7 eeb6ee3f44bd 21 months ago 204MB
17) centos:7 ์ด๋ฏธ์ง ์ญ์
docker rmi centos:7
C:\Users2>docker rmi centos:7 Untagged: centos:7 Untagged: centos@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 Deleted: sha256:eeb6ee3f44bd0b5103bb561b4c16bcb82328cfe5809ab675bb17ab3a16c517c9 Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02
18) ์ด๋ฏธ์ง ์ ์ฒด ๋ชฉ๋ก ํ์ธ
docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE kangtaegyung/ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB C:\Users2>
19) hello-world ์ปจํ ์ด๋์ ์ด๋ฏธ์ง๋ฅผ ์ญ์ ํด ์ฃผ์ธ์
(1) ์ปจํ ์ด๋ ์ ์ฒด ๋ชฉ๋ก ํ์ธ ๋ฐ ์ญ์
์ปจํ ์ด๋ ์ ์ฒด ๋ชฉ๋ก ๋ณด๊ธฐ
docker ps -a
:\Users2>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ccf0e618b725 ubuntu "bash" 17 hours ago Exited (137) 17 hours ago ubuntu 89b7101f0b41 hello-world "/hello" 18 hours ago Exited (0) 18 hours ago sweet_jang
์ปจํ ์ด๋ ์ญ์
docker rm sweet_jang
C:\Users2>docker rm sweet_jang sweet_jang
๋ค์ ์ปจํ ์ด๋ ์ ์ฒด ๋ชฉ๋ก ๋ณด๊ธฐ
C:\Users2>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ccf0e618b725 ubuntu "bash" 17 hours ago Exited (137) 17 hours ago ubuntu C:\Users2>
20) hello-world ์ด๋ฏธ์ง ์ญ์
์ฌ์ฉ๋ฒ) docker rmi ์ด๋ฏธ์ง๋ช :ํ๊ทธ
์ด๋ฏธ์ง ์ ์ฒด ๋ชฉ๋ก ๋ณด๊ธฐ
docker images
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB kangtaegyung/ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB hello-world latest 9c7a54a9a43c 4 weeks ago 13.3kB
21) ์ด๋ฏธ์ง ์ญ์ ํ๊ธฐ
docker rmi hello-world:latest
C:\Users2>docker rmi hello-world:latest Untagged: hello-world:latest Untagged: hello-world@sha256:fc6cf906cbfa013e80938cdf0bb199fbdbb86d6e3e013783e5a766f50f5dbce0 Deleted: sha256:9c7a54a9a43cca047013b82af109fe963fde787f63f9e016fdc3384500c2823d Deleted: sha256:01bb4fce3eb1b56b05adf99504dafd31907a5aadac736e36b27595c8b92f07f1
22) ๋ค์ ์ด๋ฏธ์ง ์ ์ฒด ๋ชฉ๋ก ๋ณด๊ธฐ
C:\Users2>docker images REPOSITORY TAG IMAGE ID CREATED SIZE kangtaegyung/ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB ubuntu latest 1f6ddc1b2547 2 weeks ago 77.8MB C:\Users2>