moby: docker start returns "container already exists"

Description docker start returns Error response from daemon: container <hash>: already exists This happened after I installed the latest upgrade. The only other change I did was to remove check from “Enable kubernetes” and apply that change (from docker preferences window).

Describe the results you received:

dps -a
IMAGE                                                 NAMES                PORTS                                            COMMAND                  STATUS
jetty                                                 infallible_hodgkin                                                    "/docker-entrypoint.…"   Exited (0) 2 weeks ago
jetty                                                 gallant_perlman                                                       "/docker-entrypoint.…"   Exited (1) 2 weeks ago
docker.elastic.co/elasticsearch/elasticsearch:5.6.3   st-es                0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   "/bin/bash bin/es-do…"   Exited (255) 18 minutes ago
appbaseio/mirage                                      mystifying_meitner   0.0.0.0:3030->3030/tcp                           "http-server '-p 303…"   Exited (255) 2 months ago
appbaseio/dejavu                                      heuristic_jones      0.0.0.0:1358->1358/tcp                           "http-server '-p 135…"   Exited (255) 2 months ago
mongo                                                 mongo                0.0.0.0:27017->27017/tcp                         "docker-entrypoint.s…"   Exited (255) 5 weeks ago
zookeeper                                             st-zk                2888/tcp, 0.0.0.0:2181->2181/tcp, 3888/tcp       "/docker-entrypoint.…"   Exited (255) 18 minutes ago
mysql:5.5                                             st-mysql             0.0.0.0:3306->3306/tcp                           "docker-entrypoint.s…"   Exited (255) 18 minutes ago
% 
% 
% docker start st-mysql
Error response from daemon: container "fa0db3388ad6eb043d8632039c152f58afb68dbb6a2c5a3a7721420a56518477": already exists
Error: failed to start containers: st-mysql

Output of docker version:

Client:
 Version:	18.02.0-ce-rc1
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	5e1d90a
 Built:	Thu Jan 25 00:33:50 2018
 OS/Arch:	darwin/amd64
 Experimental:	true
 Orchestrator:	swarm

Server:
 Engine:
  Version:	18.02.0-ce-rc1
  API version:	1.36 (minimum version 1.12)
  Go version:	go1.9.3
  Git commit:	5e1d90a
  Built:	Thu Jan 25 00:40:43 2018
  OS/Arch:	linux/amd64
  Experimental:	false

Output of docker info:

Containers: 8
 Running: 1
 Paused: 0
 Stopped: 7
Images: 32
Server Version: 18.02.0-ce-rc1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 157
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9b55aab90508bd389d7654c4baf173a981477d55
runc version: 9f9c96235cc97674e935002fc3d78361b696a69e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.75-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 3
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: TLZO:G2VR:E4RK:4L5T:7QZ3:56R3:WSBW:Z7XW:LQMW:AXRE:5QZU:Z3HA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 28
 Goroutines: 45
 System Time: 2018-01-30T14:51:16.971310166Z
 EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3128
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 67 (19 by maintainers)

Most upvoted comments

@arnekick

docker-containerd-ctr --namespace moby --address /run/docker/containerd/docker-containerd.sock c rm b62020cb44e1ed3307195ca4402cdf23ed817c35c52a30da858909398898c8b6

my solution for all containers: docker-containerd-ctr --address /run/docker/containerd/docker-containerd.sock --namespace moby c rm $(docker ps -aq --no-trunc)

@arnekick If you are on mac/windows you’ll need to run that command in a container.

Should be able to do something like:

 docker run -it --rm -v /:/host alpine /host/usr/local/bin/docker-containerd-ctr  --namespace moby --address /host/run/docker/containerd/docker-containerd.sock c rm b62020cb44e1ed3307195ca4402cdf23ed817c35c52a30da858909398898c8b6

This may help shed light… I came across this issue today.

Installed Docker on a Windows 10 machine that has never had docker before.

Version 18.02.0-ce-rc1 (Edge channel)

Running this command: docker run -d --hostname my-rabbit --name super-rabbit -p 8090:15672 -p 8091:5672 rabbitmq:3-management

If I stop the docker service, or restart my computer, or stop the container manually, it is impossible to get it started again.

docker start super-rabbit always give this error: Error response from daemon: container "<containerId>: already exists" Error failed to start containers:

Fixed in #36249

i’m not sure whether this is the same issue, but i’m experiencing this after an upgrade from 18.01.0-1 to 18.02.0-1 on Arch Linux and a following reboot for the first time.

edit: downgrading allowed me to use the exsiting containers. phew.

same issue with docker4mac

▶ docker -v
Docker version 18.02.0-ce-rc1, build 5e1d90a
▶ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS                      NAMES
ec0c7d0409d6        memcached:alpine    "docker-entrypoint.s…"   4 days ago          Exited (255) 2 days ago   0.0.0.0:11211->11211/tcp   my-memcache
298ff55e4058        redis:alpine        "docker-entrypoint.s…"   4 days ago          Exited (255) 2 days ago   0.0.0.0:6379->6379/tcp     my-redis

~
▶ docker start my-memcache
Error response from daemon: container "ec0c7d0409d613549a1afcb7491cd75667aca7f7eb04deeaab7407c90ef0af87": already exists
Error: failed to start containers: my-memcache

~                                                                                                                                                                   ⍉
▶ docker start my-redis
Error response from daemon: container "298ff55e4058ef157c8e865122de28c738787e2ebe5a39dbd26a2302b5b76f49": already exists
Error: failed to start containers: my-redis

I noticed the same problem after upgrade docker from 19.03.1 to 19.03.13.

I kill a process named containerd-shim -namespace moby .......... which find by:

ps aux | grep 9d79aca9890ed973309a6c25882fcf7d54dacb76a455a1ee3c8f922edfbc5e02

Then I delete a directory.

sudo rm -r /var/run/docker/runtime-runc/moby/9d79aca9890ed973309a6c25882fcf7d54dacb76a455a1ee3c8f922edfbc5e02

It works now. Thanks everyone.

My env

  • centos 7.6
  • docker 19.03.13 (after upgrade)

I solved the issue on Windows by changing the workaround posted by @cpuguy83 in this way:

docker run -it --rm -v /var/run/docker/containerd/docker-containerd.sock:/docker-containerd.sock --privileged docker:dind docker-containerd-ctr --namespace moby --address /docker-containerd.sock c rm CONTAINER_ID

I’m not an expert, so use at your own risk. Thanks everyone!


ORIGINAL: @cpuguy83 On Windows, I get the following error when trying your workaround:

docker run -it --rm -v /:/host alpine /host/usr/local/bin/docker-containerd-ctr --namespace moby --address /host/run/docker/containerd/docker-containerd.sock c rm “11060259da8b94cca3b12289ec533c68e0af261e576ce91dbf39e172ec7ae20e”

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused “exec: "/host/usr/local/bin/docker-containerd-ctr": stat /host/usr/local/bin/docker-containerd-ctr: no such file or directory”: unknown.

Entering in the container with bash reveals that the host folder is indeed missing from container. I should probably mount a different folder on Windows, but I can’t find the docker-container-ctr command anywhere.

Any help would be appreciated Thanks

I was facing the same issue when I shut down my computer without stopping the running container correctly. I ran docker rm <container> before docker run [OPTIONS] <image> and then I was able to start and stop the container again. This whole ‘problem’ wasn’t a thing in the previous version (v18.01.0-ce) though.

FYI for those looking to rollback: If you know the build number of the release you want to roll back to…and don’t have the file in your ‘Downloads’…you can always just download a prior release – if you know the build number.

For me this was ‘18.01.0-cd-mac48 (22026)’ (the version I was running before the upgrade introduced this bug), so the URL to re-download was:

https://download.docker.com/mac/edge/22026/Docker.dmg

You can replace edge with stable to get access to the Stable builds.

Stop Docker if it is currently running, and just install over it…everything is working again for me. I’ll run this version until I see that this bug has been fixed. I wrote a quick bash script, based on another Github issue about accessing older build, to surf the download server for available builds and print them out. PM me if you are interested in a copy I put the script up on Github: https://github.com/john3exonets/surfDockerBuilds.

Rollback to build 22026, 22256 not work. Finally, first edge build with Kubernetes 21669 saves me.

https://download.docker.com/mac/edge/21669/Docker.dmg

Ok, I’m investigating a number of cases where this can happen.

The main issue comes down to the fact that in the pre-1.0 containerd API, a container Create API request would actually run the container. With containerd 1.0, there are two layers of abstraction

  1. The container object, which is metadata
  2. The task object which is the runtime state of a container

To simplify integration with containerd 1.0, docker is not currently using the container object/metadata stuff and basically just deletes the container from containerd when the container is stopped/exits/whatever.

So it seems in some case (or cases) moby is not able to cleanup the container object from containerd. Most likely this is incorrect error handling in moby.

@303linuxgroup not related; that error tells that you’re trying to create two containers with the same name. That doesn’t look like a bug, but a user-error (container names must be unique). Remove the old container before creating a new container with the same name.

When I update the image tag(docker load -i xxxxx), docker is not stopped,Now my device also has this problem,I thought the new version fixes this problem Cannot create container for service xxxxxx: Conflict. The container name “xxxxxx” is already in use by container “34fb9e3986e7f79803dd1aca1e77b0b635dff719d2e39a8e38e53eab5739f513”. You have to remove (or rename) that container to be able to reuse that name.

My env:

  • CentOS 8.0
  • linux 4.19.163
  • docker version Client: Docker Engine - Community Version: 20.10.8 API version: 1.41 Go version: go1.16.6 Git commit: 3967b7d Built: Fri Jul 30 19:53:39 2021 OS/Arch: linux/amd64 Context: default Experimental: true

Server: Docker Engine - Community Engine: Version: 20.10.8 API version: 1.41 (minimum version 1.12) Go version: go1.16.6 Git commit: 75249d8 Built: Fri Jul 30 19:52:00 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.9 GitCommit: e25210fe30a0a703442421b0f60afac609f950a3 runc: Version: 1.0.1 GitCommit: v1.0.1-0-g4144b63 docker-init: Version: 0.19.0 GitCommit: de40ad0

@Eyshika You can upgrade or you can do:

 docker run -it --rm -v /:/host alpine /host/usr/local/bin/docker-containerd-ctr  --namespace moby --address /host/run/docker/containerd/docker-containerd.sock c rm b62020cb44e1ed3307195ca4402cdf23ed817c35c52a30da858909398898c8b6

Where that long ID is the ID reported as already existing when you try to start the container.

18.06 is older and does not have the fix.

@nachopro There are several work-arounds posted in this issue.

Hi, today after computer crashed my containers was never wake up again 😦

$ sudo docker start dev-mysql dev-redis dev-rabbit
Error response from daemon: container "xxxxxxxxx": already exists
Error response from daemon: container "xxxxxxxxx": already exists
Error response from daemon: container "xxxxxxxxx": already exists
Error: failed to start containers: dev-mysql, dev-redis, dev-rabbit

I’m using Docker version 18.02.0-ce, build fc4de447b5 @ ArchLinux 1 mos ago without any problem.

Any suggestion is welcome;

One way I have found to reproduce this is:

  1. Start daemon
  2. run container docker run -d --name test busybox top
  3. kill -9 <dockerd pid>
  4. Kill container process and corresponding containerd-shim process
  5. Start daemon
  6. docker start test

This would conceivably be repro’d on a reboot where dockerd was not able to properly shutdown the container on exit. The key here is that the process exits while dockerd is not processing events (i.e. when it’s down) and the shim is also killed.

The one weird thing here is that it is strange that in d4mac it seems common that docker has not processed a container exit… assuming this is happening on shutdown but again I don’t know why the container shutdown is not caught.

Unfortunately an automated test for this is not all that simple since it does require killing the containerd-shim. I will work up a fix for this case and get it backported to 17.12.

I’m not sure that I could get something in time for the Docker 18.02 release…

Latest edge channel version (Version 18.02.0-ce-rc2-mac51 (22446)) has the same issue.