Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Error response from daemon: OCI runtime create failed container_linux.go:380: starting container process caused

I have this error after running this command in PowerShell docker-compose up My Docker Version Docker version 20.10.7, build f0df350 My Docker Info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-beta.6)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 12.43GiB
 Name: docker-desktop
 ID: 65YS:IH5I:4VI6:ZBXX:SB7J:NAR5:OSHP:OQ3S:ZGHX:653Z:KSFS:3CKX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

Error

[+] Running 5/6
 - Network project_default          Created                                                                        0.7s
 - Volume "project_mongo-db"        Created                                                                        0.0s
 - Container project_mongo_1        Started                                                                       12.4s
 - Container project_node-app_1     Starting                                                                      12.9s
 - Container project_react-app_1    Created                                                                        8.9s
 - Container project_nginx-proxy_1  Created                                                                        0.1s
Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/var/lib/docker/volumes/4b1671442c7499623e352a827a29d54b514fd4f186b937181a90ab497d12995c/_data" to rootfs at "/usr/src/server/node_modules" caused: mkdir /var/lib/docker/overlay2/c11386ffc7cd58452b395472bb289e20df441f5b59e1082d6d055de466b81a4e/merged/usr/src/server/node_modules: read-only file system: unknown

This project I get from my friend. My friend didn't have Dockerfile in project folder but have just: Project Folder In Windows 10 File Explorer

So I find so many tutorials and I find how to use docker-compose. It's like going well but I have this error. I find this error in google but no one can help me even in the StackOverflow. Thanks For Helping!!! :)

docker-compose.yml:

version: '3.4'

services:
    nginx-proxy:
        restart: always
        build:
            context: ./
            dockerfile: ./nginx-proxy/Dockerfile
        ports:
            - '${NGINX_PROXY_PORT}:${NGINX_PROXY_PORT}'
        environment:
            - NGINX_LE_PLACEHOLDER_1=${PORT}
            - NGINX_LE_PLACEHOLDER_2=${SERVER_PORT}
            - NGINX_LE_PLACEHOLDER_3=${NGINX_PROXY_PORT}
            - NGINX_LE_TZ
        depends_on:
            - node-app
            - react-app

    react-app:
        build:
            context: ./
            dockerfile: ./client/Dockerfile
        volumes: 
            - ./client:/usr/src/client:ro
            - /usr/src/client/node_modules
        depends_on: 
            - node-app
        environment: 
            - NODE_ENV=development
            - CHOKIDAR_USEPOLLING=true
        ports:
            - '${PORT}:${PORT}'
  
    node-app:
        build: 
            context: ./
            dockerfile: ./server/Dockerfile
        volumes:
            - ./server:/usr/src/server:ro
            - /usr/src/server/node_modules
        environment:
            - NODE_ENV=development
        env_file:
            - ./.env
        ports:
            - '${SERVER_PORT}:${SERVER_PORT}'
        depends_on:
            - mongo
  
    mongo:
        image: mongo:latest
        volumes:
            - mongo-db:/data/db
        ports: 
            - "27017:27017"
        environment: 
            - MONGO_INITDB_ROOT_USERNAME=
            - MONGO_INITDB_ROOT_PASSWORD=
volumes:
    mongo-db:

React Project Dockerfile (client):

FROM node:16-alpine3.11

RUN apk add --update git
WORKDIR /usr/src/client
ENV PATH /usr/src/client/node_modules/.bin:$PATH

COPY ./client/package.json ./
RUN npm install --legacy-peer-deps --silent

COPY ./client ./

CMD [ "npm", "start" ]

nginx proxy folder Docker:

FROM 0x8861/nginx-le:v2.0.0
COPY ./nginx-proxy/templates/no-ssl.service.conf.dev /etc/nginx/no-ssl.service.conf

Node.js App Dockerfile (server):

FROM node:lts-buster
WORKDIR /usr/src/server
COPY ./server/package*.json ./
RUN npm install
COPY ./.env ../.env
CMD ["npm", "run", "dev"]

My Dockerfile Name: Dockerfile Image

Thanks again to those who can help! :) and if this is duplicate am so sorry but I can't find how to fix it thanks again :) Another thing I tried doing it by a single project folder it can but have another error. and my friend suggest using docker-compose.

like image 623
Deknoinarak Avatar asked Aug 03 '21 13:08

Deknoinarak


People also ask

What is OCI runtime create failed?

This usually occurs due to a bad command being passed to one of the secondary service containers in your job. The error message occurs due to the secondary service container crashing or exiting prematurely. This means CircleCI cannot get the PID from the Docker daemon and exits with a failure.

How do I run an image in Docker?

To run an image inside of a container, we use the docker run command. The docker run command requires one parameter and that is the image name. Let's start our image and make sure it is running correctly.

What is -- RM in Docker run?

The --rm causes Docker to automatically remove the container when it exits. The image being used to create the container is generally specified as <name>:<tag> such as ruby:latest . If the specified image is not available locally, Docker will attempt to retrieve it from Docker Hub (or any connected Docker registry).

Why is my OCI running in Docker not working?

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "/bin/ucp-tool": stat /bin/ucp-tool: no such file or directory": unknown. Usually, this error occurs due to an incorrect flag set up in the Docker systemD unit file.

What are some common Docker daemon error messages?

docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "/hello": stat /hello: no such file or directory: unknown. if you try the simples possible image and get this error you have found the information to solve your problem.

Why can’t I start a docker container?

Isn’t it frustrating if you can’t even start a Docker container? Usually, the Docker oci runtime error occurs due to improper namespace setup or system file errors. Start-up errors in Docker containers always need an immediate fix.

How to fix Docker-Runc is not working?

If the docker daemon version is 18.09, you should be having runc or else docker-runc. Show activity on this post. To check the issue by run docker in the debug mode. Then check the output in docker debug console in 2. And solve it by removing the container state folder with rm -rf /var/run/docker/runtime-runc/moby/docker_id


Video Answer


1 Answers

It looks like you're trying to replace the application code in the image with different code using Docker bind mounts. Docker's general model is that a container runs a self-contained image; you shouldn't need to separately install the application code on the host.

In particular, these two volumes: blocks cause the error you're seeing, and can safely be removed:

services:
  react-app:
    build:             # <-- This block builds an image with the code
      context: ./
      dockerfile: ./client/Dockerfile
    # volumes:         # <-- So delete this block
    #   - ./client:/usr/src/client:ro
    #   - /usr/src/client/node_modules
  node-app:
    build: 
      context: ./
      dockerfile: ./server/Dockerfile
    # volumes:         # <-- And this one
    #   - ./server:/usr/src/server:ro
    #   - /usr/src/server/node_modules

Mechanically, the first volumes: line replaces the image's code with different code from the host, but with a read-only mount. The second volumes: line then further tries to replace the node_modules directory with an old copy from an anonymous volume. This will create the node_modules directory if it doesn't exist yet; but the parent directory is a read-only volume mount, resulting in the error you're seeing.

like image 66
David Maze Avatar answered Oct 19 '22 06:10

David Maze