Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
146 views
in Technique[技术] by (71.8m points)

php - docker-compose down default_network error

I have a docker-compose with some php, mysql and so on starting. After a few days, I cannot bring them down as everything stopps instead of mysql. It always gives me the following error:

ERROR: network docker_default has active endpoints

this is my docker-compose.yml

version: '2'
services:
  php:
    build: php-docker/.
    container_name: php
    ports:
      - "9000:9000"
    volumes:
      - /var/www/:/var/www/
    links:
      - mysql:mysql
    restart: always

  nginx:
    build: nginx-docker/.
    container_name: nginx
    links:
      - php
      - mysql:mysql
    environment:
      WORDPRESS_DB_HOST: mysql:3306
    ports:
      - "80:80"

    volumes:
      - /var/log/nginx:/var/log/nginx
      - /var/www/:/var/www/
      - /var/logs/nginx:/var/logs/nginx
      - /var/config/nginx/certs:/etc/nginx/certs
      - /var/config/nginx/sites-enabled:/etc/nginx/sites-available
    restart: always

  mysql:
    build: mysql-docker/.
    container_name: mysql
    volumes:
      - /var/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: pw
      MYSQL_USER: florian
      MYSQL_PASSWORD: pw
      MYSQL_DATABASE: database
    restart: always


  phpmyadmin:
    build: phpmyadmin/.
    links:
     - mysql:db
    ports:
     - 1234:80
    container_name: phpmyadmin
    environment:
     PMA_ARBITRARY: 1
     PMA_USERNAME: florian
     PMA_PASSWORD: pw
     MYSQL_ROOT_PASSWORD: pw
    restart: always

docker network inspect docker_default gives me:

[
    {
        "Name": "docker_default",
        "Id": "1ed93da1a82efdab065e3a833067615e2d8b76336968a2591584af5874f07622",
        "Created": "2017-03-08T07:21:34.969179141Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "85985605f1c0c20e5ee9fedc95800327f782beafc0049f51e645146d2e954b7d": {
                "Name": "mysql",
                "EndpointID": "84fb19cd428f8b0ba764b396362727d9809cd1cfea536e648bfc4752c5cb6b27",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

UPDATE

Seems that docker rm mysql -f stopped the mysql container, but the network is running.

Removed the network with docker network disconnect -f docker_default mysql But I'm pretty interested in how I got into this situation. any ideas?

question from:https://stackoverflow.com/questions/42842277/docker-compose-down-default-network-error

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm guessing you edited the docker-compose file while you were currently running...?

Sometimes if you edit the docker-compose file before doing a docker-compose down it will then have a mismatch in what docker-compose will attempt to stop. First run docker rm 8598560 to stop the currently running container. From there, make sure you do a docker-compose down before editing the file. Once you stop the container, docker-compose up should work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...