问题描述
运行 docker-compose up -d
我得到以下错误:
Running docker-compose up -d
I got the following error:
Starting cr-redis ...
Starting cr-rabbitmq ...
Starting cr-rabbitmq ... error
Starting cr-redis ... error
Starting cr-mysql ... error
ERROR: for cr-mysql Cannot start service mysql: container "ff36...1116": already exists
ERROR: for rabbitmq Cannot start service rabbitmq: container "3b6c...0aba": already exists
ERROR: for redis Cannot start service redis: container "e84f...df91": already exists
ERROR: for mysql Cannot start service mysql: container "ff36...1116": already exists
ERROR: Encountered errors while bringing up the project.
docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------
cr-mysql docker-entrypoint.sh mysqld Exit 255
cr-php-fpm /bin/sh -c /usr/sbin/php-f ... Exit 255 9000/tcp
cr-rabbitmq docker-entrypoint.sh rabbi ... Exit 255
cr-redis docker-entrypoint.sh redis ... Exit 255
cr-webserver nginx -g daemon off; Exit 255 0.0.0.0:15672->15672/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:9003->9003/tcp
如何在不重新创建容器的情况下重新启动容器?我只是不想丢失数据库中的数据.
How can I start again the container without recreating it? I just don't want to lose the data in the DB.
--------------更新------------
--------------- UPDATE --------------------
$ docker-compose stop
$ docker-compose start
Starting redis ... error
Starting rabbitmq ... error
Starting mysql ... error
Starting php-fpm ... error
Starting webserver ... error
ERROR: for rabbitmq Cannot start service rabbitmq: container "3b6c...0aba": already exists
ERROR: for mysql Cannot start service mysql: container "ff36...1116": already exists
ERROR: for redis Cannot start service redis: container "e84f...f91": already exists
ERROR: No containers to start
推荐答案
您的案例可能与将在 18.03
版本中修复的错误有关.此处提出了一些解决方法:
Your case is probably related to a bug that will be fixed in the 18.03
release. Some workarounds are proposed here:
docker-compose up
为服务构建、(重新)创建、启动和附加到容器.
docker-compose up
builds, (re)creates, starts, and attaches to containers for a service.
既然你的 images
已经构建并且你的服务的 containers
已经启动,你就可以使用
Since your images
are built and the containers
of your service have started, you can then use
docker-compose stop
和docker-compose start
启动/停止您的服务.这与 docker-compose down
不同:
to start/stop your service. This is different from docker-compose down
which:
停止容器并删除由 up
创建的容器、网络、卷和图像.
Stops containers and removes containers, networks, volumes, and images created by
up
.
<小时>
关于移除容器后丢失数据的危险,请阅读持久存储以及如何使用卷.
这篇关于Docker无法启动服务,因为已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论