Original URL: Docker Compose Network Series--docker-compose connects to the host network
Introduction
illustrate
This article describes how to implement docker-compose to connect to the host network.
demand scene
The container under services in docker-compose.yml cannot be connected to the host network. The method to allow multiple applications to connect to the network: set networks in docker-compose.yml and designate it as the host network.
The purpose of this article
1 docker compose to connect with the host: app (halo) and the host.
The method of docker compose
1. Add the following configuration to the first-level configuration of each docker-compose.yml:
networks:
custom_app_net:
name: host
external: true
2. The services that need to be connected to the network plus the network configuration:
services:
app:
# image:
# container_name:
# ports:
# volumes:
# environment:
networks:
- custom_app_net
The docker method
docker xxx --net app_net