docker 容器容器之间网络通信 docker-compose.yaml 配置固定ip
1、创建自己的桥接网络
$ docker network create --subnet=172.18.0.0/16 mynetwork
2、docker-compose.yaml 文件格式demo
version: "3.1"
networks:
default:
external:
name: gjnetwork
services:
api:
container_name: api
image: image-name
ports:
- "5000:80"
restart: always
volumes:
- "/data/web/Attachments:/Attachments"
networks:
default:
ipv4_address: 172.18.0.10
3、容器运行后可以查看容器内部网络
docker inspect containerId
4、进入容器查看内部结构
docker exec -it 容器ID /bin/bash
5、退出容器内部 执行exit