docker-compose指定已有网络

version: '2'
services:
  mariadb:
    container_name: mariadb-zhongjiao
    image: jcmariadb:v1
    restart: always
    networks:
      jc:
        ipv4_address: 172.18.5.58
    volumes:
    - type: volume
      source: mariadbdata
      target: /var/lib/mysql
  mongo:
    container_name: mongodb-zhongjiao
    image: jcmongodb:v1
    restart: always
    networks:
      jc:
        ipv4_address: 172.18.5.59
    volumes:
    - type: volume
      source: mongodata
      target: /data/db
  redis:
    container_name: redis-zhongjiao
    image: jcredis:v1
    restart: always
    networks:
      jc:
        ipv4_address: 172.18.5.60
    volumes:
    - type: volume
      source: redisdata
      target: /data
  api:
    container_name: api-zhongjiao
    image: openjdk:ffmpeg
    restart: always
    networks:
      jc:
        ipv4_address: 172.18.5.61
  userWeb:
    container_name: user-zhongjiao
    image: nginx:1.14
    restart: always
    networks:
      jc:
        ipv4_address: 172.18.5.62
  web:
    container_name: web-zhongjiao
    image: nginx:1.14
    restart: always
    networks:
      jc:
        ipv4_address: 172.18.5.63
volumes:
  mongodata:
  mariadbdata:
  redisdata:
networks:
  jc:
    external: true

添加网络服务,制定名称,是否未外部网络设置为true

你可能感兴趣的:(docker,网络,容器)