0

I want to assign new port mapping to my existing container, so i changed the /var/lib/docker/containers/{containerid}/hostconfig.json and config.v2.json files.

But after changing, I lost my docker container...

The missing container does not appear through docker ps -a command. But it still exists in /var/lib/docker/containers

(Plus) I tried to start my lost container by container id, using sudo docker start {container_id} command. But it also does not work.

Error response from daemon: No such container: e96f84691fff

What should I do? Please help me

Alez
  • 1,913
  • 3
  • 18
  • 22
Sebin H
  • 1
  • 2
  • Do this help you to solve your problem ? https://stackoverflow.com/questions/19335444/how-do-i-assign-a-port-mapping-to-an-existing-docker-container/38783433#38783433 – PRATHEESH PC Jul 17 '23 at 07:33
  • Hi PRATHEESH, actually I tried to change port mapping after seeing that answer on stack overflow. But it doesn't work for me. One suspicious thing is that the docker service didn't seem to shut down completely when I modified the config file. – Sebin H Jul 17 '23 at 07:42
  • You should `docker stop` and `docker rm` your existing container, and `docker run` a new one with the correct port mapping. Never modify the files in `/var/lib/docker`. A container is just a wrapper around a process and isn't especially valuable; think of this the same way as if you had started a program with the wrong command-line arguments. – David Maze Jul 17 '23 at 10:10
  • Hi David, I didn't know about that... Thank you for your comment! – Sebin H Jul 18 '23 at 02:25

0 Answers0