Ask Your Question

Is it possible to repair a file within a docker container that has failed to start?

asked 2021-11-11 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-20 05:00:00 +0000

devzero gravatar image

Yes, it is possible to repair a file within a Docker container that has failed to start by accessing the file system of the container and making the necessary changes.

Here are the steps to repair a file within a Docker container:

  1. Start a new container from the same image as the failed container with a shell:
docker run -it --name=repair-container <image> /bin/bash
  1. Mount the failed container's file system to the new container.
docker run -it --name=repair-container --volumes-from <failed-container> <image> /bin/bash
  1. Once inside the container, navigate to the directory where the failed file is located and make the necessary changes.

  2. Exit the container and commit the changes to a new image.

docker commit repair-container <new-image>
  1. Use the new image to start a new container.
docker run -d --name=new-container <new-image>

The new container should now be running with the repaired file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2021-11-11 11:00:00 +0000

Seen: 14 times

Last updated: Sep 20 '21