๋์ปค ๋ช ๋ น์ด
docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
์ต์ | ์ค๋ช |
---|---|
-d , --detach | detached mode (๋ฐฑ๊ทธ๋ผ์ด๋ ๋ชจ๋) |
-p , --publish | Host์ ์ปจํ ์ด๋์ Port๋ฅผ ์ฐ๊ฒฐ (fowarding) |
-v , --volume | Host์ ์ปจํ ์ด๋์ Directory ์ฐ๊ฒฐ (๋ง์ดํธ) |
-e , --env | ์ปจํ ์ด๋ ๋ด์์ ์ฌ์ฉํ ํ๊ฒฝ๋ณ์ ์ค์ |
-it | -i์ -t๋ฅผ ๋์์ ์ฌ์ฉํ ๊ฒ์ผ๋ก ํฐ๋ฏธ๋ ์ ๋ ฅ์ ์ํ ์ต์ |
--rm | ํ๋ก์ธ์ค ์ข ๋ฃ์ ์ปจํ ์ด๋ ์๋ ์ ๊ฑฐ |
--link | ์ปจํ ์ด๋ ์ฐ๊ฒฐ[์ปจํ ์ด๋๋ช :๋ณ์นญ] |
--name | ์ปจํ ์ด๋ ์ด๋ฆ ์ค์ |
๋์ปค ์คํ์ค์ธ์ง ํ์ธ docker version
C:\Users\bactoria>docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:06:28 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:14:32 2018
OS/Arch: linux/amd64
Experimental: false
C:\Users\bactoria>
์ฐ๋ถํฌ ์ด๋ฏธ์ง ๋ค์ด๋ก๋ docker pull ubuntu:16.04
C:\Users\bactoria>docker pull ubuntu:16.04
16.04: Pulling from library/ubuntu
22dc81ace0ea: Pull complete
1a8b3c87dba3: Pull complete
91390a1c435a: Pull complete
07844b14977e: Pull complete
b78396653dae: Pull complete
Digest: sha256:e348fbbea0e0a0e73ab0370de151e7800684445c509d46195aef73e090a49bd6
Status: Downloaded newer image for ubuntu:16.04
C:\Users\bactoria>
์ด๋ฏธ์ง ํ์ธํ๊ธฐ docker images
C:\Users\bactoria>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 f975c5035748 2 weeks ago 112MB
C:\Users\bactoria>
์ฐ๋ถํฌ ์ปจํ
์ด๋ ์คํํ๊ธฐ docker run -it --name myUbuntu ubuntu:16.04 /bin/bash
C:\Users\bactoria>docker run -it --name myUbuntu ubuntu:16.04 /bin/bash
root@27db33196683:/#
๋ฆฌ๋
์ค ์ ์ ํ์ธํ๊ธฐ ls
root@27db33196683:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@27db33196683:/#
์ฐ๋ถํฌ ์ปจํ
์ด๋ ์ข
๋ฃํ๊ธฐ exit
root@27db33196683:/# exit
exit
C:\Users\bactoria>
์คํ์ค์ธ ์ปจํ
์ด๋ ํ์ธํ๊ธฐ docker ps
C:\Users\bactoria>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
C:\Users\bactoria>
๋ชจ๋ ์ปจํ
์ด๋ ํ์ธํ๊ธฐ docker ps -a
C:\Users\bactoria>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be76370e89aa ubuntu:16.04 "/bin/bash" 45 seconds ago Exited (0) 15 seconds ago myUbuntu
C:\Users\bactoria>
์ข
๋ฃ๋ ์ฐ๋ถํฌ ์ปจํ
์ด๋ ์คํํ๊ธฐ docker start myUbuntu
C:\Users\bactoria>docker start myUbuntu
myUbuntu
C:\Users\bactoria>
์ฐ๋ถํฌ ์ปจํ
์ด๋ ์ ์ํ๊ธฐ docker attach myUbuntu
+ Enter X2
C:\Users\bactoria>docker attach myUbuntu
root@be76370e89aa:/#
root@be76370e89aa:/#
์ฐ๋ถํฌ ์ปจํ
์ด๋ ๋น ์ ธ๋๊ฐ๊ธฐ Ctrl+p
+ Ctrl+q
(์ปจํ
์ด๋ ์ข
๋ฃํ์ง ์์)
root@be76370e89aa:/#
root@be76370e89aa:/# read escape sequence
C:\Users\bactoria>
์คํ์ค์ธ ๋ชจ๋ ์ปจํ
์ด๋ ํ์ธํ๊ธฐ docker ps
C:\Users\bactoria>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be76370e89aa ubuntu:16.04 "/bin/bash" 5 minutes ago Up 3 minutes myUbuntu
C:\Users\bactoria>
์ฐ๋ถํฌ ์ปจํ
์ด๋ ์ข
๋ฃํ๊ธฐ docker stop myUbuntu
C:\Users\bactoria>docker stop myUbuntu
myUbuntu
C:\Users\bactoria>
์ด๋ฏธ์ง ์ ๊ฑฐํ๊ธฐ docker rmi ubuntu:16.04
(์ญ์ ์๋จ)
C:\Users\bactoria>docker rmi ubuntu:16.04
Error response from daemon: conflict: unable to remove repository reference "ubuntu:16.04" (must force) - container be76370e89aa is using its referenced image f975c5035748
C:\Users\bactoria>
์ปจํ
์ด๋ ์ ๊ฑฐํ๊ธฐ docker rm myUbuntu
(์ด๋ฏธ์ง ์ ๊ฑฐํ๋ ค๋ฉด ์ปจํ
์ด๋ ๋จผ์ ์ ๊ฑฐํด์ผ ํจ)
C:\Users\bactoria>docker rm myUbuntu
myUbuntu
C:\Users\bactoria>
์ปจํ
์ด๋ ์ ๊ฑฐ ํ์ธ docker ps -a
(์ญ์ ๋์ด์ ์์ด์ก์๊ฑฐ์)
C:\Users\bactoria>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
C:\Users\bactoria>
์ด๋ฏธ์ง ๋ณด๊ธฐ docker images
C:\Users\bactoria>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 f975c5035748 2 weeks ago 112MB
C:\Users\bactoria>
์ด๋ฏธ์ง ์ญ์ ํ๊ธฐ docker rmi ubuntu:16.04
C:\Users\bactoria>docker rmi ubuntu:16.04
Untagged: ubuntu:16.04
Untagged: ubuntu@sha256:e348fbbea0e0a0e73ab0370de151e7800684445c509d46195aef73e090a49bd6
Deleted: sha256:f975c50357489439eb9145dbfa16bb7cd06c02c31aa4df45c77de4d2baa4e232
Deleted: sha256:0bd983fc698ee9453dd7d21f8572ea1016ec9255346ceabb0f9e173b4348644f
Deleted: sha256:08fe90e1a1644431accc00cc80f519f4628dbf06a653c76800b116d3333d2b6d
Deleted: sha256:5dc5eef2b94edd185b4d39586e7beb385a54b6bac05d165c9d47494492448235
Deleted: sha256:14a40a140881d18382e13b37588b3aa70097bb4f3fb44085bc95663bdc68fe20
Deleted: sha256:a94e0d5a7c404d0e6fa15d8cd4010e69663bd8813b5117fbad71365a73656df9
C:\Users\bactoria>
๋ฌด์์ ์ ๋ฅผ ์ฐฝ์กฐํ๊ณ
๋ค์ ๋ฌด๋ก ๋์๊ฐ๋ค.
์๋ณด๊ณ ์ฐ๋ถํฌ ์ปจํ ์ด๋ ์์ฑ๊น์ง ๊ฐ์ฆ์~
- ์ปจํ ์ด๋ attach ์๋ ๋ ์ปจํ ์ด๋ restart ํ๊ณ ๋์ ๋ค์ attach ๋ถ์ด์. ( attach ๋ช ๋ น ํ ์ํฐ ํ๋ฒ ๋๋๋ฌ ์ค์ผํจ. )
- ๋์ปค์ด๋ฏธ์ง ๊ฐ์๊ธฐ ๋ ๋ผ๊ฐ๋ ์ด๊ฑด hyper์ vm์ด๋ ๊ด๋ จ๋๊ฑฐ๊ฐ์๋ฐ.. ์์ธํ ๋ชฐ๊ฒ ์. ํ๋ฒ์ฉ ๋งํฑ์ด๊ฐ ๊ฐ๋๋ฐ
docker version
์์ Server๊ฐ ์๋ฐ ๋ hyper-V ๊ด๋ฆฌ์๋ฅผ ์ด์ด ๊ฐ์๋จธ์ ์ด ์คํ์ค์ธ์ง ํ์ธ