Reserve Docker Network Aws Vpc uses

  • docker_aws_vpc.sh
    1
    2
    3
    4
    5
    6
    7
    
    #!/bin/bash
    
    # to prevent docker to pickup 172.31.0.0/16
    docker network \
    create \
    --subnet 172.31.253.0/30 \
    aws_vpc
    

While you are developing, it is convenient if you are using VPN to access AWS VPC.

But, some times you may experience some of container cannot access AWS Resources.

In that case, the container might be being assigned docker network that is overwrapping with AWS VPC network.

To prevent this to happen, you can create docker network that is same as AWS VPC to not to be used as container network.

๋กœ์ปฌ ๊ฐœ๋ฐœํ™˜๊ฒฝ์„ ์‚ฌ์šฉํ•˜๋ฉด์„œ, AWS VPC๋ฅผ VPN์œผ๋กœ ์—ฐ๊ฒฐํ•ด์„œ ์‚ฌ์šฉํ•˜๋˜๊ฐ€ ํ•˜๋ฉด, VPC์•ˆ์— ์ƒ์„ฑํ•œ ๋„คํŠธ์›Œํฌ๋ฅผ ๋ฐ”๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์–ด์„œ, ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ, docker ๊ฐœ๋ฐœํ™˜๊ฒฝ์„ ๊ณ„์† ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด, ์–ด๋–ค ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ๋Š”๋ฐ, ํ•ด๋‹น ์ปจํ…Œ์ด๋„ˆ์—์„œ AWS Resource๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

๊ทธ ๊ฒฝ์šฐ, ํ•ด๋‹น ์ปจํ…Œ์ด๋„ˆ๊ฐ€ docker network๋ฅผ ํ• ๋‹น ๋ฐ›์„ ๋•Œ, AWS VPC์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋„คํŠธ์›Œํฌ์— ๊ฒน์น˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฐ ๊ฒฝ์šฐ๋ฅผ ์‚ฌ์ „์— ๋ฐฉ์ง€ํ•˜๊ณ ์ž, docker network์— ๋ฏธ๋ฆฌ AWS VPC์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋Œ€์—ญ์„ ์žก์•„ ๋‘๊ฒŒ ๋˜๋ฉด, ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ƒ๊ธธ ๋•Œ, ํ•ด๋‹น ๋„คํŠธ์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋„๋ก ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Related Content