修改docker镜像IP

1.创建网络

docker network create --driver bridge --subnet 100.168.0.0/24 my_network

2.修改docker-compose启动文件

version: "2"
services:
  situation-awareness-web:
    restart: always
    image: situation-awareness-web:0.1.0
    container_name: situation-awareness-web
    links:
      - situation-awareness-server
    ports:
      - "8083:80"
    networks:
      my_network:
        ipv4_address: 100.168.0.6
    volumes:
      - /data/nginx/situationAwareness/conf.d:/etc/nginx/conf.d
      - /data/nginx/situationAwareness/logs:/var/log/nginx

  situation-awareness-server:
    restart: always
    image: situation-awareness-server:0.1.0
    container_name: situation-awareness-server
    networks:
      my_network:
        ipv4_address: 100.168.0.7
    volumes:
      - /data/situationAwareness:/data/situationAwareness
    environment:
      DB_HOST: 10.248.148.193
      DB_PORT: 3306
      DATA_BASE: situation_awareness
      DB_USERNAME: root
      DB_PASSWORD: t46C9jeR
      REDIS_HOST: 10.248.148.193
networks:
  my_network:
    external: true

3.查看镜像占用的网络
docker inspect 镜像名|grep "IPAddress"
4.route -n 查看网络
5.查看docker网络 docker network ls
6.删除网络

docker network rm f3561e05e749

7.重启镜像

你可能感兴趣的:(docker,tcp/ip,容器)