0Pricing
Docker & Kubernetes for Developers · 강의

Docker Compose 네트워크로 컨테이너 연결하기

Docker Compose로 여러 컨테이너로 구성된 애플리케이션을 정의하고, 서비스 이름을 사용해 자동으로 생성된 브리지 네트워크에서 서로 통신하게 해 보세요.

Docker Compose 네트워크로 컨테이너 연결하기은(는) CoddyKit의 무료 Docker & Kubernetes for Developers 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Docker & Kubernetes for Developers 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Why Compose for Networking

Running many containers and wiring their networks by hand is tedious. Docker Compose describes your whole stack in one YAML file and creates a dedicated network so services can find each other.

The Default Compose Network

When you run docker compose up, Compose creates a single user-defined bridge network for the project. Every service joins it automatically, so no manual docker network create is needed.

Service Names as Hostnames

On a Compose network, each service is reachable by its service name via built-in DNS. A service named db is reachable at the hostname db from any other service.

A Minimal Compose File

Two services on one network: a web app and a database.

version: "3.9"
services:
  web:
    image: myapp:latest
    ports:
      - "8080:80"
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: secret

Connecting to db by Name

Inside the web container, the connection string points to the service name, not an IP:

DATABASE_URL=postgres://postgres:secret@db:5432/postgres

Defining Custom Networks

You can declare named networks to isolate groups of services.

services:
  web:
    image: myapp
    networks: [frontend]
  api:
    image: myapi
    networks: [frontend, backend]
  db:
    image: postgres
    networks: [backend]
networks:
  frontend:
  backend:

Network Isolation in Practice

In the example above, web can reach api but NOT db, because they share no network. This limits the blast radius if a frontend container is compromised.

Exposing vs Publishing Ports

expose makes a port reachable only to other containers on the network. ports publishes it to the host. Internal services like databases should usually only be exposed, never published.

Aliases for Services

You can give a service extra DNS names with aliases, handy when migrating from an old hostname.

services:
  db:
    image: postgres
    networks:
      backend:
        aliases:
          - database
          - legacy-db
networks:
  backend:

Connecting to External Networks

Set a network as external: true to attach services to a network created outside this Compose file, sharing it across projects.

networks:
  shared:
    external: true

Inspecting the Network

List and inspect the network Compose created to confirm which containers are attached.

docker network ls
docker network inspect myproject_default

Quick Check

Test what you have learned.

Recap

You learned that Docker Compose creates a network per project, lets services talk by service name, and supports custom networks for isolation, expose vs ports, aliases, and external networks.

자주 묻는 질문

“Docker Compose 네트워크로 컨테이너 연결하기” 강의는 무료인가요?

네 — “Docker Compose 네트워크로 컨테이너 연결하기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Docker & Kubernetes for Developers 강의 전체를 잠금 해제할 수 있습니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.

“Docker Compose 네트워크로 컨테이너 연결하기”에서 뭘 배우나요?

Docker Compose로 여러 컨테이너로 구성된 애플리케이션을 정의하고, 서비스 이름을 사용해 자동으로 생성된 브리지 네트워크에서 서로 통신하게 해 보세요. 브라우저에서 직접 실행하는 실습 코드로 Docker & Kubernetes for Developers을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Docker & Kubernetes for Developers을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Docker & Kubernetes for Developers은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“Docker Compose 네트워크로 컨테이너 연결하기” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Docker & Kubernetes for Developers 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Docker & Kubernetes for Developers 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Docker 네트워크 유형 이해
  2. 컨테이너 네트워크 구성
  3. 볼륨을 활용한 데이터 지속성
  4. Docker Compose 네트워크로 컨테이너 연결하기
← Docker & Kubernetes for Developers(으)로 돌아가기