正在运行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
如何在不重新创建容器的情况下重新启动容器?我只是不想丢失数据库中的数据。
---------------更新--------------------
$ 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
答案 0 :(得分:4)
您的案例可能与将在18.03
版本中修复的错误有关。这里提出了一些解决方法:
docker-compose up
构建,(重新)创建,启动和附加服务的容器。
由于您构建了images
并且服务的containers
已经开始,您可以使用
docker-compose stop
和docker-compose start
开始/停止您的服务。这与docker-compose down
不同,后者:
停止容器并移除由
up
创建的容器,网络,卷和图像。
关于删除容器时丢失数据的危险,请阅读持久存储以及如何使用卷。
答案 1 :(得分:2)
您需要使用docker-compose start
代替:
$ docker-compose start --help
Start existing containers.
Usage: start [SERVICE...]