Docker无法启动已存在的服务 [英] Docker Cannot start service as already exists
问题描述
运行 docker-compose up -d
我遇到以下错误:
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 $ c $中修复。 c>释放。此处提出一些解决方法:
Your case is probably related to a bug that will be fixed in the 18.03
release. Some workarounds are proposed here:
- https://github.com/docker/for-linux/issues/211
- https://github.com/moby/moby/issues/36145
docker-compose up
构建,(重新)创建,启动并附加到服务容器。
docker-compose up
builds, (re)creates, starts, and attaches to containers for a service.
由于您的图片
已构建,并且服务的个容器
已启动,然后可以使用
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 stop
anddocker-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
.
关于如果删除容器会丢失数据的危险,请阅读有关永久存储以及如何使用卷的信息。
Regarding the danger of losing your data if a container is removed, read about persistent storage and how to use volumes.
这篇关于Docker无法启动已存在的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!