Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose up error, Invalid address

I want to use elastic's docker-elk, then I cloned elastic github code. And I want to use a specific ip for every container, so I define a specific ip for every container, when I run docker-compose up, I meet the error

ERROR: for elasticsearch  Cannot start service elasticsearch: Invalid address 172.18.1.3: It does not belong to any of this network's subnets
ERROR: Encountered errors while bringing up the project.

it shows no any of network's subnet, but I define the subnet, and docker-compose.yml like this

version: '2'

services:

  elasticsearch:
    build: elasticsearch/      
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      elk:
        ipv4_address: 172.18.1.3

  logstash:
    build: logstash/
    ports:
      - "5000:5000"
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      elk:
        ipv4_address: 172.18.1.4
    depends_on:
      - elasticsearch

  kibana:
    build: kibana/
    ports:
      - "5601:5601"
    networks:
      elk:
        ipv4_address: 172.18.1.5
    depends_on:
      - elasticsearch

networks:

  elk:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.1.0/24

and docker version

Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:20:36 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:21:56 2017
 OS/Arch:      linux/amd64
 Experimental: false
like image 459
xina1i Avatar asked Aug 12 '17 09:08

xina1i


2 Answers

I just ran into this issue and my issue seems to be issues with how docker caches networks and containers. I had to docker network rm the network that was previously created. I also had to docker ps -a and docker rm the previously created containers as they're cached to use the network that you'll be removing. After I removed all those leftover artifacts, it started up correctly.

like image 111
chizou Avatar answered Sep 25 '22 11:09

chizou


Use docker-compose down and try to run docker-compose up. This works with me

like image 22
Isuru Dilshan Avatar answered Sep 25 '22 11:09

Isuru Dilshan