docker-compose up
Specify any IP address of the host network and start it up.
Basics are unnecessary and I think the correct way is to use service discovery such as nginx-proxy or treafik. However, I think there are rare use cases like ↓ that can not be done with that, so I will leave it as a memorandum.
--When you want to fix the IP such as in-house infrastructure --When you want to shift the IP and avoid port booking --8080,8081,8082 ... I want to see which port is free so that it will not be a battle
Use the macvlan
network driver.
docker-compose.yml
version: "3.8"
services:
web01:
image: nginx
networks:
macvlan:
ipv4_address: 192.168.1.10
# ports
# - "80:80"I want to see docker's host network, the port is fully open with the specified IP, so the basics are unnecessary
...etc
web01:
image: nginx
networks:
macvlan:
ipv4_address: 192.168.1.20
# ports
# - "80:80"Port does not book because IP is different
...etc
...etc
networks:
macvlan:
driver: macvlan
driver_opts:
parent: eno1 #Specify the network interface of the terminal
ipam:
config:
- subnet: 192.168.1.0/24
gateway: 192.168.1.1
Recommended Posts