使用Docker 报错OCI runtime exec failed: exec failed: unable to start container process: exec: “xxx“: exe

A few days ago, when I was using Docker to run a container, I encountered an error: OCI runtime exec failed: exec failed: unable to start container process: exec: “xxx“: exec.

This error made me a little annoyed because I had just created the container and when I was about to execute the relevant commands, I found that the container could not start normally. After some troubleshooting and trying, I finally found the solution and now I share it with you.

First, we need to clarify the cause of this error, which usually occurs under the following circumstances:

  • Necessary dependencies are missing inside the container.
  • The executable file inside the container does not exist or is corrupted.

Therefore, we can take the following steps to solve this problem:

Step 1: Check the container’s startup command

First, we need to check whether the container startup command is correct. We can use the following command to view the startup command of the container:

docker inspect <container-id>

Among them, <container-id> is the ID of the container.

If you find that the startup command is wrong, you can use the following command to modify it:

docker update --restart=no <container-id>

Among them, --restart=no it means that the container will not restart automatically.

Step 2: Check the dependencies inside the container

Next, we need to go inside the container and check whether the dependencies inside the container are missing or corrupted. We can get inside the container using the following command:

docker exec -it <container-id> /bin/bash

Among them, -it it means using the interactive terminal to enter the container, and /bin/bash it means using the Bash command line interface.

After entering the container, we can use  ls commands to check whether the files and directories inside the container exist. If you find that a dependency is missing or broken, you can manually install or repair it.

Step 3: Restart the Docker service

If the above two steps cannot solve the problem, then we can try to restart the Docker service. We can use the following command to restart the Docker service:

systemctl restart docker

Then restart the container to see if it can run normally.

Summarize

When using Docker to run containers, it is very common to encounter errors. Errors like OCI runtime exec failed are usually caused by missing dependencies or damaged executable files inside the container. We can solve this problem by checking the container startup command, checking the container's internal dependencies, and restarting the Docker service.

Guess you like

Origin blog.csdn.net/javamendou/article/details/131327328