Skip to main content

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349

Summary

Hi, fellow cat-head-hu bloggers! Today, we’re going to take a deep dive into a vexing issue in the cloud-native world, the error you encounter when using Docker: docker: Error response from daemon: OCI runtime create failed: container_linux.go:349. This article will provide a detailed analysis of the root cause of this problem, how to solve it, and how to avoid similar situations. Let's solve this bug together!

introduction

Docker has become one of the standard tools for modern application development and deployment, but during use, we sometimes encounter various problems. One of the common and troublesome problems is that OCI runtime create fails, especially in Linux environment. There are some deep-seated problems hidden behind this error message that require careful study and resolution.

Bug cause analysis

First, let’s dig into the cause of this error. OCI runtime create failed error messages usually mean that Docker was unable to successfully create a container's runtime environment. The root cause of this problem can be divided into the following aspects:

  1. Linux kernel incompatibility : OCI (Open Container Initiative) is an open standard for container runtimes. If your Linux kernel version is too low or is not compatible with the OCI standard, it may cause OCI runtime create to fail.

  2. Container configuration problems : There may be problems with the container's configuration file, such as missing necessary parameters or improper parameter settings, which may cause the container to fail to be created normally.

  3. Insufficient resources : Containers require certain system resources, including CPU, memory, etc. If system resources are insufficient, OCI runtime create may fail.

Solution

Now that we know the possible reasons for OCI runtime create failure, let's solve these problems one by one.

  1. Check the Linux kernel version

First, you need to make sure your Linux kernel version is compliant with Docker's requirements. Please consult the official Docker documentation to find out the minimum kernel version required for the Docker version you are using, and make sure your system kernel is upgraded to meet the requirements.

$ uname -r
$ sudo apt-get update
$ sudo apt-get install linux-image-<your_required_kernel_version>
  1. Check container configuration

Check your Docker container configuration file to make sure all parameters are set correctly. Pay special attention to mounted volumes, network configuration and other configuration items related to OCI runtime.

# Example Docker Composite Configuration
version: '3'
services:
myapp:
image: myapp:latest
volumes:
- /host/path:/container/path
# Other configuration items

  1. Resource management

If the OCI runtime create failure is related to insufficient system resources, you may consider adjusting the resource limits of the Docker container. Use Docker Compose or the Docker command line to set appropriate CPU and memory limits.

# Docker Composite Configuration Example
version: '3'
services:
myapp:
image: myapp:latest
resources:
limits:
cpus: '0.5' # Limit CPU usage to 50%
memory: 512M # Limit memory to 512MB

How to avoid similar problems

To avoid OCI runtime create failure, you can take the following measures:

  1. Regularly update the system kernel to maintain compatibility with Docker.

  2. Use container orchestration tools such as Docker Compose or Kubernetes to manage containers and reduce the chance of manual configuration errors.

  3. Monitor system resource usage to ensure that containers do not overuse resources.

Summarize

In cloud native application development, Docker is an indispensable tool, but it will encounter various problems during use, and the failure of OCI runtime create is one of them. This article provides an in-depth analysis of the cause of the problem, a solution, and suggestions for avoiding similar problems. I hope this article helps you better understand and deal with this common bug.