Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker can't start because docker container with id exists?

Tags:

docker

My docker container can't restart after I upgrade the docker to Docker version 17.06.2-ce. The error message and my compose file are following:

Starting wordpress ... error
Starting mysql     ... error

ERROR: for wordpress  Cannot start service wordpress: oci runtime error: container with id exists: 
b3951fd8b599c273f39d3b29085d525828a92dabe518f42860ba6535d5edad6e


ERROR: for mysql  Cannot start service mysql: oci runtime error: container with id exists: be9c3682bb66720c8015cfe9e9025c68a917204444e9b77f68b63d84f0469b71


======================

the docker compose file is:

services:
  wordpress:
    image: wordpress
    restart: always
    ports:
      - 80:80
    environment:
      WORDPRESS_DB_PASSWORD: xxx

  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: xxx

I have reboot the instance but not working. Need your help!

like image 948
alphonese qi Avatar asked Nov 11 '17 12:11

alphonese qi


People also ask

How do I go inside a not running Docker container?

When we try to run /bin/sh on a stopped container using docker exec , Docker will throw a No such container error. We have to transform the stopped Docker container into a new Docker image before we can inspect the internals of the container. We can transform a container into a Docker image using the commit command.

How do I start Docker daemon on Mac?

On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced. You can also start the Docker daemon manually and configure it using flags. This can be useful for troubleshooting problems. Many specific configuration options are discussed throughout the Docker documentation.


2 Answers

Have you tried to remove the stopped containers from your docker engine?

You can show all container with docker ps -a. This will give you a list of the local containers (stopped and running). Identify the old wordpress and mysql containers and remove them with docker rm <container-id>. After removing the old containers you should be able to run your docker compose file again.

like image 144
dpr Avatar answered Sep 22 '22 09:09

dpr


This is because the system was restarted abnormally and the container was left in a bad state. To find the state information:

find -name "b3951fd8b599c273f39d3b29085d525828a92dabe518f42860ba6535d5edad6e"

That should result in something like:

/run/docker/runtime-runc/moby/b3951fd8b599c273f39d3b29085d525828a92dabe518f42860ba6535d5edad6e

You can remove the state information with:

sudo rm -rf /run/docker/runtime-runc/moby/b3951fd8b599c273f39d3b29085d525828a92dabe518f42860ba6535d5edad6e/

Then start the container fresh with:

docker start b395

Then you should be up and running.

like image 26
Jimi D Avatar answered Sep 20 '22 09:09

Jimi D