When docker enters the container, it reports an error OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd (“

Project Scenario and Problem Description

When Docker creates an image and writes a Dockerfile, it defines a certain directory under the root directory, taking the directory /Xxx as an example. Since this directory will not be used later, the directory is deleted when using the container. After exiting the container, the container cannot be entered again, and an error occurs.
The instruction to enter the container is: (the first three digits of the CONTAINER ID of the container are 92v)

docker exec -it 92v /bin/bash

The error is as follows:

OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/Xxx") set in config.json failed: no such file or directory: unknown

Cause Analysis:

From the ("/Xxx") set in config.json in the error report, it can be seen that the general reason for this error report is that the folder defined when Docker was created is now gone.


solution:

The solution is very simple and crude. You can define a folder with the same name outside the container, use docker cpthe command to copy the folder with the same name into the container, and the location of the directory defined when the container was first created. Take the /Xxx folder defined in the root directory in the container at the beginning as an example. The first three digits of the container’s CONTAINER ID are 92v, and a new empty directory /Xxx with the same name is created outside the container, and its absolute path is /home/Sss/Yyy/ Xxx/. Copy the empty directory into the container with the following command:

docker cp /home/Sss/Yyy/Xxx/ 92v:/Xxx/

Then enter the container:

docker exec -it 92v /bin/bash

Reporting an error will solve it. Successfully entered the container and can be used normally~

Guess you like

Origin blog.csdn.net/qq_39691492/article/details/130846961