Skip to content

Latest commit

ย 

History

History
292 lines (199 loc) ยท 6.61 KB

03. Docker-command.md

File metadata and controls

292 lines (199 loc) ยท 6.61 KB

๋„์ปค ๋ช…๋ น์–ด ์ตํžˆ๊ธฐ ( + ์šฐ๋ถ„ํˆฌ ์„ค์น˜ )


๋„์ปค ๋ช…๋ น์–ด

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>


๋ฌด์—์„œ ์œ ๋ฅผ ์ฐฝ์กฐํ•˜๊ณ 

๋‹ค์‹œ ๋ฌด๋กœ ๋Œ์•„๊ฐ”๋‹ค.

์•ˆ๋ณด๊ณ  ์šฐ๋ถ„ํˆฌ ์ปจํ…Œ์ด๋„ˆ ์ƒ์„ฑ๊นŒ์ง€ ๊ฐ€์ฆˆ์•„~



Issues

  • ์ปจํ…Œ์ด๋„ˆ attach ์•ˆ๋ ๋•Œ ์ปจํ…Œ์ด๋„ˆ restart ํ•˜๊ณ ๋‚˜์„œ ๋‹ค์‹œ attach ๋ถ™์ด์ž. ( attach ๋ช…๋ น ํ›„ ์—”ํ„ฐ ํ•œ๋ฒˆ ๋”๋ˆŒ๋Ÿฌ ์ค˜์•ผํ•จ. )

  • ๋„์ปค์ด๋ฏธ์ง€ ๊ฐ‘์ž๊ธฐ ๋‚ ๋ผ๊ฐˆ๋•Œ ์ด๊ฑด hyper์— vm์ด๋ž‘ ๊ด€๋ จ๋œ๊ฑฐ๊ฐ™์€๋ฐ.. ์ž์„ธํžˆ ๋ชฐ๊ฒ ์Œ. ํ•œ๋ฒˆ์”ฉ ๋ง›ํƒฑ์ด๊ฐ€ ๊ฐ€๋˜๋ฐ

  • docker version์—์„œ Server๊ฐ€ ์•ˆ๋œฐ ๋•Œ hyper-V ๊ด€๋ฆฌ์ž๋ฅผ ์—ด์–ด ๊ฐ€์ƒ๋จธ์‹ ์ด ์‹คํ–‰์ค‘์ธ์ง€ ํ™•์ธ