๋„์ปค ๋ช…๋ น ๐Ÿณ

5146 ๋‹จ์–ด

๋„์ปค ์ด๋ฏธ์ง€ ๋ช…๋ น


  • docker images ๋ช…๋ น์— ๋Œ€ํ•œ ๋„์›€๋ง์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

  • docker images --help 
    


  • ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

  •  docker pull [image] `
    


  • ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™€์„œ ํƒœ๊ทธ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

  •  docker pull [image]:[tag] 
    


  • ๋กœ์ปฌ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์˜ ๋ชจ๋“  ์ด๋ฏธ์ง€๋ฅผ ๋‚˜์—ดํ•ฉ๋‹ˆ๋‹ค.

  •  docker images 
    


  • ์ด๋ฏธ์ง€ ID๋งŒ ๋‚˜์—ด

  •  docker images -q 
    


  • ๋งค๋‹ฌ๋ฆฐ ์ด๋ฏธ์ง€ ๋‚˜์—ด

  •  docker images -f "dangling=true" 
    


  • ์ƒˆ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  •  docker run [image] 
    


  • ์‹คํ–‰ ์ค‘์ธ ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‚˜์—ดํ•ฉ๋‹ˆ๋‹ค.
  • docker ps
  • ์ƒˆ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์ด๋ฆ„์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

  •  docker run --name [container] [image] 
    


  • ์ƒˆ๋กœ์šด ๋Œ€ํ™”ํ˜• ์ปจํ…Œ์ด๋„ˆ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  •  docker run -it [image] 
    


  • ์ƒˆ ๋Œ€ํ™”ํ˜• ์ปจํ…Œ์ด๋„ˆ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ์ด๋ฆ„์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

  •  docker run -it --name [container] [image] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค.

  •  docker inspect [container] 
    


  • ๋กœ์ปฌ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

  •  docker rmi [image] 
    


  • ๋กœ์ปฌ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ๊ฐ•์ œ๋กœ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

  •  docker rmi -f [image] 
    


  • ์ด๋ฏธ์ง€์˜ ๊ธฐ๋ก์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

  •  docker history [image] 
    


    ๋„์ปค ์ปจํ…Œ์ด๋„ˆ ๋ช…๋ น


  • ์‹คํ–‰ ์ค‘์ธ ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‚˜์—ดํ•ฉ๋‹ˆ๋‹ค.

  •  docker ps 
    


  • ์ƒˆ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  •  docker run [image] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

  •  docker start [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.

  •  docker stop [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ผ์‹œ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.

  •  docker pause [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ์˜ ์ผ์‹œ ์ค‘์ง€๋ฅผ ํ•ด์ œํ•ฉ๋‹ˆ๋‹ค.

  •  docker unpause [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

  •  docker restart [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ์˜ ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

  •  docker top [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ์˜ ๋ฆฌ์†Œ์Šค ์‚ฌ์šฉ๋Ÿ‰์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

  •  docker stats [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๊ฒ€์‚ฌํ•ฉ๋‹ˆ๋‹ค.

  •  docker inspect [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ์— ๋ถ€์ฐฉํ•ฉ๋‹ˆ๋‹ค.

  •  docker attach [container-name] / [container-id] 
    


    docker attach ์‚ฌ์šฉ๋ฒ• : docker attach๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ„ฐ๋ฏธ๋„์˜ ํ‘œ์ค€ ์ž…๋ ฅ, ์ถœ๋ ฅ ๋ฐ ์˜ค๋ฅ˜(๋˜๋Š” ์„ธ ๊ฐ€์ง€ ์กฐํ•ฉ)๋ฅผ ์ปจํ…Œ์ด๋„ˆ์˜ ID ๋˜๋Š” ์ด๋ฆ„์„ ์‚ฌ์šฉํ•˜์—ฌ ์‹คํ–‰ ์ค‘์ธ ์ปจํ…Œ์ด๋„ˆ์— ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ช…๋ น์ด ํ„ฐ๋ฏธ๋„์—์„œ ์ง์ ‘ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์ง„ํ–‰ ์ค‘์ธ ์ถœ๋ ฅ์„ ๋ณด๊ฑฐ๋‚˜ ๋Œ€ํ™”์‹์œผ๋กœ ์ œ์–ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ฃฝ์ž…๋‹ˆ๋‹ค.

  •  docker kill [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

  •  docker rm [container-name] / [container-id] 
    


  • ์ปจํ…Œ์ด๋„ˆ์˜ ๊ธฐ๋ก์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

  •  docker history [container-name] / [container-id] 
    


    ๋„์ปค ํŒŒ์ผ ๋ช…๋ น


  • Dockerfile์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•ฉ๋‹ˆ๋‹ค.

  •  docker build [path] 
    


  • Dockerfile์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•˜๊ณ  ํƒœ๊ทธ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

  •  docker build -t [image] [path] 
    


    ๋„์ปค ์ž‘์„ฑ ๋ช…๋ น


  • ์„œ๋น„์Šค์˜ ๊ตฌ์„ฑ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

  •  docker compose config [service] 
    


  • ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

  •  docker-compose up [service] 
    


  • ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•˜๊ณ  ๊ณ„์† ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  •  docker-compose up -d [service] 
    


  • ์„œ๋น„์Šค๋ฅผ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค.

  •  docker-compose down [service] 
    


  • ์‹คํ–‰ ์ค‘์ธ ๋ชจ๋“  ์„œ๋น„์Šค๋ฅผ ๋‚˜์—ดํ•ฉ๋‹ˆ๋‹ค.

  •  docke compose ps 
    

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ