Docker containers restart fails

2019-06-11 20:48发布

问题:

Hello I have 2 docker container: one for wordpress and the other for the DB. I want to copy html and php files in the wordpress container for that I saw that it must first stop the container otherwise the copy will not be done. Except that after the copy in the container if I do :

docker restart $(docker ps -a -q)

I have this error :

Error response from daemon: Cannot restart container 035714167b27: network 87e28d3e4121e59f1a3dab6e0afc81db6f273e2585fe22045f3dcd7edcd3ae5d not found
Error response from daemon: Cannot restart container 2169bed03e64: network 87e28d3e4121e59f1a3dab6e0afc81db6f273e2585fe22045f3dcd7edcd3ae5d not found

And even if I restart the containers one by one I have the error : for example :

Error response from daemon: Cannot restart container 035714167b27: network 87e28d3e4121e59f1a3dab6e0afc81db6f273e2585fe22045f3dcd7edcd3ae5d not found

Here is my docker-compose.yml file :

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    networks:
      - database
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: ******
      WORDPRESS_DB_NAME: exampledb

  db:
    image: mysql:5.7
    restart: always
    networks:
      - database
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '********'
networks:
  database:

Error for docker-compose up command :

Starting wordpress_db_1        ... error
Starting wordpress_wordpress_1 ...

Starting wordpress_wordpress_1 ... error

ERROR: for wordpress_wordpress_1  Cannot start service wordpress: network 87e28d3e4121e59f1a3dab6e0afc81db6f273e2585fe22045f3dcd7edcd3ae5d not found

ERROR: for db  Cannot start service db: network 87e28d3e4121e59f1a3dab6e0afc81db6f273e2585fe22045f3dcd7edcd3ae5d not found

ERROR: for wordpress  Cannot start service wordpress: network 87e28d3e4121e59f1a3dab6e0afc81db6f273e2585fe22045f3dcd7edcd3ae5d not found
ERROR: Encountered errors while bringing up the project.

And for docker-compose down command :

Removing wordpress_wordpress_1 ... done
Removing wordpress_db_1        ... done
Removing network wordpress_database

Output of the docker network ls command:

NETWORK ID          NAME                  DRIVER              SCOPE
13f1e50b9b01        nat                   nat                 local
82f0375abab2        nat                   nat                 local
9b6e4eb573bd        none                  null                local
3c58f55f0ae6        wordpress_database    nat                 local
90581f5a1c1d        wordpress_default     nat                 local
03cc07eda9e8        wordpress_wordpress   nat                 local

Information :

  1. Windows 10
  2. Docker Version 2.0.0.2 (30215)

Thank you in advance !!!

回答1:

You are using docker compose for starting? If so, probably the network is removed when the last container of a network exits. I would not copy the files manuelly, use a volume binding, that should remove the need to copy files into a container, which is a huge red flag