Docker容器重启失败

时间:2019-01-30 14:38:23

标签: docker containers

你好,我有2个docker容器:一个用于wordpress,另一个用于DB。我想在wordpress容器中复制html和php文件,因为我看到它必须首先停止容器,否则将无法完成复制。除非我在容器中复制了之后:

docker restart $(docker ps -a -q)

我遇到此错误:

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

即使我一个接一个地重新启动容器,我也会遇到错误:例如:

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

这是我的docker-compose.yml文件:

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:

docker-compose up命令出错:

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.

对于docker-compose down命令:

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

docker network ls命令的输出:

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

信息:

  1. Windows 10
  2. Docker版本2.0.0.2(30215)

预先感谢您!

1 个答案:

答案 0 :(得分:1)

您正在使用docker compose进行启动吗? 如果是这样,则可能在网络的最后一个容器退出时删除了该网络。 我不会手动复制文件,而是使用卷绑定,这样就无需将文件复制到容器中了,这是一个巨大的危险信号