-1

I accidentally removed a docker container. docker rm blablabla

Before I did so I created a json config file with docker container inspect blablabla output.json

Is there a way to recreate/rerun this with the json file?

Also this was a Postgres container. Does it mean I lost all my data?

KingKongFrog
  • 13,946
  • 21
  • 75
  • 124
  • there is no way. you can generate container with docker compose with the inspect export. what you can do is that you can go through the file manually and extract the information important for you and create a docker compose out of it. – Micheal Choudhary May 24 '23 at 17:30
  • Many of the recipes in [How to show the run command of a docker container](https://stackoverflow.com/questions/32758793/how-to-show-the-run-command-of-a-docker-container) or [See full command of running/stopped container in Docker](https://stackoverflow.com/questions/27380641/see-full-command-of-running-stopped-container-in-docker) start from `docker inspect` output; do those questions help? You need to migrate back from the JSON output to `docker run` options, which should generally be possible, but there isn't an out-of-the-box tool to do it. – David Maze May 24 '23 at 18:17

1 Answers1

1

Is there a way to recreate/rerun this with the json file?

No.

Does it mean I lost all my data?

That depends on where your "data" were saved. If they were inside the container, it is lost. If inside a volume, it may be there. If on a mounted filesystem, they also may be there. See the json spec where was it saved.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • I see this in the mounts: "Mounts": [ { "Type": "volume", "Name": "blablabla-db", "Source": "/var/lib/docker/volumes/blablabla-db/_data", "Destination": "/var/lib/postgresql/data", "Driver": "local", "Mode": "z", "RW": true, "Propagation": "" } ], ` – KingKongFrog May 24 '23 at 17:40
  • `/var/lib/docker/volumes/blablabla-db/_data` `blablabla-db` – KamilCuk May 24 '23 at 17:41