๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ
๐Ÿคท๐Ÿผ‍โ™€๏ธ Etc.../- linux, aws, docker, k8s

[Docker] docker system prune ์œผ๋กœ ๋„์ปค์—์„œ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋ชจ๋“  ๋ฆฌ์†Œ์Šค ์‚ญ์ œํ•˜๊ธฐ

by Wonit 2021. 6. 11.

Docker ๋ฅผ ์ด์šฉํ•˜๋‹ค ๋ณด๋ฉด ์šฐ๋ฆฌ๋Š” ์—ฌ๋Ÿฌ ๋Œ€์˜ ์ปจํ…Œ์ด๋„ˆ๋“ค์„ ๋‹ค๋ฃจ๊ฒŒ ๋œ๋‹ค.

 

์—ฌ๋Ÿฌ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‹ค๋ฃจ๋ฉด์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋ฆฌ์†Œ์Šค๋“ค์— ๋Œ€ํ•œ ๊ด€๋ฆฌ ์ด๋‹ค.

 

์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋ฆฌ์†Œ์Šค๋ผ๋ฉด ๋ฌด์—‡์ผ๊นŒ?

 

์˜ˆ๋ฅผ ๋“ค์–ด์„œ ์šฐ๋ฆฌ๊ฐ€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ํ•˜๋‚˜๋ฅผ ๊ฐœ๋ฐœํ–ˆ๊ณ , ์ด๋ฅผ ๋ฐฐํฌํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„ ๋•Œ ํ•ด๋‹น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ปจํ…Œ์ด๋„ˆํ™” ํ•œ ์ด๋ฏธ์ง€๋“ค์„ ๋ฐ”๋กœ๋ฐ”๋กœ ์‚ญ์ œํ•˜์ง€ ์•Š์•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ด๋ณด์ž.

 

๊ทธ๋Ÿผ์— ๋”ฐ๋ผ์„œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ปจํ…Œ์ด๋„ˆ๋‚˜ Docker Network ๋Š” Host PC ์— ์Œ“์ด๊ฒŒ ๋œ๋‹ค.

 

๋„์ปค๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ๊ฐœ๋ฐœ์ž์ผ ์ˆ˜๋ก Host PC ์„ฑ๋Šฅ์— ๋งŽ์€ ์˜ํ–ฅ์„ ๋ฏธ์น˜๊ฒŒ ๋œ๋‹ค.

 

์ด ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด๊ฐ€ ๋ฐ”๋กœ system์˜ prune ๋ช…๋ น์–ด์ด๋‹ค.

 

prune

 

prune์€ ๊ฐ€์ง€ ์น˜๊ธฐ์™€ ๊ฐ™์ด ๋ถˆํ•„์š”ํ•œ ๋ฌด์–ธ๊ฐ€๋ฅผ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ ์ฏค์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

 

์ด prune ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ปจํ…Œ์ด๋„ˆ ๋ฆฌ์†Œ์Šค๋ฅผ ๋ชจ๋‘ ์—†์• ๋ณด์ž.

 

$ docker system prune

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N] y

docker system prune ์„ ์น˜๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ WARNING์ด ๋œจ๊ฒŒ ๋œ๋‹ค.

 

์ด๋Š” prune ๋ช…๋ น์–ด๋ฅผ ์กฐ์‹ฌ์Šค๋Ÿฝ๊ฒŒ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•˜๊ณ  docker ๊ฐ€ ์•Œ๋ ค์ฃผ๋Š” ๊ฒƒ ์ฒ˜๋Ÿผ ๋งŽ์€ ๋ถˆํ•„์š”ํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ญ์ œํ•œ๋‹ค.

 

  1. ๋ฉˆ์ถฐ์žˆ๋Š” ๋ชจ๋“  ์ปจํ…Œ์ด๋„ˆ
  2. ์ตœ์†Œ ํ•œ ๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” ๋„คํŠธ์›Œํฌ
  3. ๋งค๋‹ฌ๋ ค์žˆ๋Š” (๋ถˆํ•„์š”ํ•œ, ๋ถ€์ˆ˜์ ์ธ) ์ด๋ฏธ์ง€
  4. ๋งค๋‹ฌ๋ ค์žˆ๋Š” (๋ถˆํ•„์š”ํ•œ, ๋ถ€์ˆ˜์ ์ธ) ๋นŒ๋“œ ์บ์‹œ

 

์ด๋ฅผ ์—ผ๋‘ํ•˜๊ณ  ๋งŒ์•ฝ ์‚ญ์ œํ•˜๊ธธ ์›ํ•œ๋‹ค๋ฉด y ๋ฅผ ์ณ์„œ ์‚ญ์ œ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋งŽ์€ ์ปจํ…Œ์ด๋„ˆ๋“ค์ด ์‚ญ์ œ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

 

 

๋‚˜์˜ ๊ฒฝ์šฐ๋Š” ์ด 8.3 GB๋‚˜ ์‚ญ์ œ๋˜์—ˆ๋‹ค.

 

 

๋Œ“๊ธ€