[Docker] ์‹คํ–‰์ค‘์ธ Container Port Forwarding ๋‹ค์‹œ ํ•˜๊ธฐ

2023. 7. 8. 16:34ใ†System ์ž‘์—…์‹ค/Docker

728x90
๋ฐ˜์‘ํ˜•

 




 

 

 

๐Ÿš€ [Docker] ์‹คํ–‰์ค‘์ธ Container Port Forwarding ๋‹ค์‹œ ํ•˜๊ธฐ

    ๐Ÿ”ฝ ๊ฐœ์š”

        ๐Ÿ“ฆ ์†Œ๊ฐœ

์ฃผ๋‹ˆ๋Š” ํ˜„์žฌ ์ด ์ „์— ๋งŒ๋“ค์—ˆ๋˜ systemd๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Ubuntu Docker๋ฅผ ๊ฐ€์ง€๊ณ , ์—ฌ๋Ÿฌ๊ฐ€์ง€๋กœ ํ™œ์šฉํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ด ์•ˆ์— ์–ด๋–ค Application์„ ์„ค์น˜ํ•˜์˜€์„ ๋•Œ, ํฌํŠธ ํฌ์›Œ๋”ฉ์„ ํ•˜์ง€ ์•Š๊ณ , ์ง„ํ–‰์„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ž‘์—…์ด ์™„๋ฃŒํ•˜๊ณ , ๋‚˜์„œ ๊ต‰์žฅํžˆ ๋‚œ๊ฐํ•œ ์ƒํ™ฉ์„ ๋งŒ๋‚  ์ˆ˜ ์žˆ์—ˆ์–ด์š”.

๊ทธ๋ž˜์„œ ์ด๋ฏธ ๊ตฌ๋™์ค‘์ธ Container์— ํฌํŠธ ํฌ์›Œ๋”ฉ ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ๋ณด๋ ค๊ณ  ํ•ด์š”.

 

 

 

    ๐Ÿ”ฝ ์‹คํ–‰์ค‘์ธ Docker Container Port Forwarding


์ตœ์ดˆ ์ฃผ๋‹ˆ๊ฐ€ ์ž‘์—…ํ•  ๋‘ ๊ฐœ์˜ Container ์ค‘ giggal-logstash๋ฅผ ์ž‘์—…ํ•ด ๋ณด๋„๋ก ํ• ๊ฒŒ์š”.

์ผ๋‹จ ๊ธฐ๋™์ค‘์ธ Container๋ฅผ ๋ฉˆ์ถฐ์ฃผ๋„๋ก ํ• ๊ฒŒ์š”.


docker stop <Container ID>

 


๋ฉˆ์ถ˜ Container๋ฅผ Docker Image๋กœ ๋งŒ๋“ค์–ด ์ค„ ๊ฑฐ์—์š”.

docker commit <๋Œ€์ƒ Container ID> <๋งŒ๋“ค Docker Image ์ด๋ฆ„>

 

 

docker images

 

 

728x90


๋ช…๋ น์–ด๋ฅผ ์ง์ ‘ ์ž…๋ ฅํ•ด์ค˜๋„ ๋˜์ง€๋งŒ, ์ฃผ๋‹ˆ๋Š” ์œ„์™€ ๊ฐ™์ด shell Script๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.

-p๋ฅผ ํ†ตํ•ด Host์™€ ํฌํŠธ ํฌ์›Œ๋”ฉ์„ ํ•ด์ฃผ์—ˆ์–ด์š”.


docker rm <Container ID>

 

 


๊ธฐ์กด์— ๋™์ž‘ํ•˜๋˜ Container๋ฅผ ์‚ญ์ œ ํ•ด ์ฃผ๊ณ , Shell Script๋ฅผ ํ†ตํ•ด ์ƒˆ๋กญ๊ฒŒ Container๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.

๋ฐ˜์‘ํ˜•


์ด๋ ‡๊ฒŒ ํฌํŠธ ํฌ์›Œ๋”ฉ์ด ๊ฑธ๋ฆฐ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

 





๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

๊ฐ„๋‹จํ•˜๊ฒŒ ์‹คํ–‰ ์ค‘์ธ docker container์— ํฌํŠธํฌ์›Œ๋”ฉ ๋‹ค์‹œ ์„ค์ •ํ•˜๊ธฐ

๋„์ปค์— ์„ผํ† ์Šค(์ปจํ…Œ์ด๋„ˆ)๋ฅผ ์˜ฌ๋ ค์„œ ๋ฐฐํฌํ•˜๊ณ  ์ ‘๊ทผํ•˜๋ ค๋ฉด ์ฒ˜์Œ๋ถ€ํ„ฐ ๋„์ปค๋ฅผ runํ• ๋•Œ ํฌํŠธํฌ์›Œ๋”ฉ์„ ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ๋„์ปค ๋„คํŠธ์›Œํฌ ํŠน์„ฑ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ฒ˜์Œ ์‚ฌ์šฉํ•  ๋•Œ ๋ชจ๋ฅด๊ณ  ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋งŒ๋“ค์—ˆ

pjs21s.github.io

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•