Sometimes you may have changed a configuration in a Docker container with an entry script and the container has broken after the restart. In such case you may find it difficult to start the container back. Docker has provided with the most simplest way to fix broken docker containers.
First of all you want to check what is broken. You can look at the logs the container has generated with
$ docker logs --tail 100 <container_name>
The –tail switch will print only the last lines of the log and you can replace 100 with the number of lines you want to print.
Once you have debugged the issue you can then isolate the file that you want to change using docker cp. Yes! This works on stopped containers as well
$ docker cp <container_name>:/path/to/file /path/to/copy
Once you have made the change you can copy back the fixed file to the container with the same command but changing the arguments order
$ docker cp /path/to/fixed/file <container_name>:/path/to/file
A Big Thanks to this answer – https://stackoverflow.com/a/50166314/1223387 from Tomurie
*Please Note: Make sure that you know what you are doing. Otherwise you are at risk to lose all / any data and render the Docker container to be unusable permanently
post via Codincafe