Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't restart docker container: OCI runtime create failed: container with id exist

I'm a new in a Docker, and I've tried to find solution in the google befor ask question - no result.

I decided to learn docker via practical use case - create PostgreSQL container into my VM instance for develop enviroment. I've been in vacation and didn't check my server several days. Later I tried to connect to my DB, and couldnt - all of my active containers was exited with code 128. I tried to start again container with DB - docker start django-postgres and got error message - Error response from daemon: OCI runtime create failed: container with id exists: 5c11e724bf52dd1cb6fd10ebda40710385e412981eb269c30071ecc8aac9e805: unknown Error: failed to start containers: django-postgres

I suspect that somewhere in my system docker keeps some metadata of my container which didn't removed after container was down with code 128, but my knowledge of unix doesn't enough to determine where is it can be. Also, I'm affraid of lost my DB data connected with container.

Some techincal info: docker version:

Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:10:01 2018 OS/Arch: linux/amd64 Experimental: false Orchestrator: swarm

docker info

Containers: 9
 Running: 2
 Paused: 0
 Stopped: 7
Images: 5
Server Version: 18.03.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: 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: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-116-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 488.3MiB
ID: NDUH:OH24:4M4L:TR5O:TOIH:ARV4:LNRP:6QNE:WEYW:TMXR:7KNK:ZPDD
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Does anyone can help my understand my issue and how to fix it without lost data?

N.B. The second container that has been exited with code 128 was OpenVPN. I can't restart it also, but error was differ - cgroups: cannot found cgroup mount destination: unknown I found solution here (github):

Temp fix is
sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd

This fix coudn't helped with Postgres container.

like image 629
kotmsk Avatar asked Oct 17 '22 20:10

kotmsk


1 Answers

It is possible to list all running and stopped containers using docker ps -a. -a or --all Show all containers (default shows just running).

You can find the volumes attached to your old postgres container using docker inspect <container-id> (Maybe pipe to less and search for volumes)

If you want to recover your data, you can attach it to a new postgres container and recover it. (If it is a root volume change target to /)

docker run --name new-postgres \
--mount source=myoldvol,target=/var/lib/postgresql/data -d postgres

And then you can remove the old one by using docker rm <container-id>.

For more information please see,

docker ps, docker volumes, docker rm

like image 65
raghulmz Avatar answered Oct 21 '22 01:10

raghulmz