Docker Error response from daemon: OCI runtime create failed container_linux.go:380: starting container process caused
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.
Deknoinarak
Updated on July 09, 2022Comments
-
Deknoinarak almost 2 years
I have this error after running this command in PowerShell
docker-compose up
My Docker VersionDocker version 20.10.7, build f0df350
My Docker InfoClient: 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:
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"]
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.