Docker无法启动服务,因为已经存在

编程入门 行业动态 更新时间:2024-10-17 05:38:17
本文介绍了Docker无法启动服务,因为已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 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:

https://github/docker/for-linux/issues/211https://github/moby/moby/issues/36145

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 stopdocker-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:关键词]

本文发布于:2023-03-31 03:44:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/794960.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法启动   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!