skip to Main Content

I am new to Ubuntu and new to Docker. I am running a command that was given to me in an explanation of how to start the project. I want to start my Docker containers and they fail with an error.

Some notes:

  • It is a new Ubuntu laptop.
  • I added Docker to have sudo privileges. groups yields docker among the list it responds with.

Here’s the command I use to start it: docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build

And it gives:

Step 11/12 : EXPOSE $PORT
 ---> Using cache
 ---> 7620427ebfe9
Step 12/12 : CMD ["ts-node", "./src/server.ts"]
 ---> Using cache
 ---> 00a32820e6e2
Successfully built 00a32820e6e2
Successfully tagged backend-marketplace_backend:latest
backend-marketplace_database_1 is up-to-date
Starting backend-marketplace_backend_1 ... 
Starting backend-marketplace_backend_1 ... error

ERROR: for backend-marketplace_backend_1  Cannot start service backend: failed to create shim task: 
OCI runtime create failed: runc create failed: unable to start container process: error during container init: 
error mounting "/var/lib/docker/volumes/3ceff6572cda1981f7d29faf09f888cb9a8c0c5ac41b10bb323eb5d14e7e1d35/_data" 
to rootfs at "/app/node_modules": mkdir /var/lib/docker/overlay2/c0a5b761bb9a94bb9a4dd3c21a862968dbbabe87698c0f744569ea56e323ea0e/merged/app/node_modules: 
read-only file system: unknown

ERROR: for backend  Cannot start service backend: failed to create shim task: 
OCI runtime create failed: runc create failed: unable to start container process: error during container init: 
error mounting "/var/lib/docker/volumes/3ceff6572cda1981f7d29faf09f888cb9a8c0c5ac41b10bb323eb5d14e7e1d35/_data" to rootfs at 
"/app/node_modules": mkdir /var/lib/docker/overlay2/c0a5b761bb9a94bb9a4dd3c21a862968dbbabe87698c0f744569ea56e323ea0e/merged/app/node_modules: 
read-only file system: unknown
ERROR: Encountered errors while bringing up the project.

I see docker-compose.yml and docker-compose.dev.yml mentioned so here they are:

docker-compse.yml:

version: "3"
services:
  backend:
    build: .
    ports:
      - "8000:8000"
    env_file:
      - ./.env

and docker-compose.dev.yml:

version: "3"
services:
  backend:
    build:
      context: .
      args:
        NODE_ENV: development
    volumes:
      - ./:/app:ro
      - /app/node_modules
    links:
      - database
    env_file:
      - ./.env
    command: npm run dev
  database:
    image: "postgres:latest"
    volumes:
      - pgdata:/var/lib/postgresql/data
    expose:
      - "5432"
    ports:
      - "5432:5432"
    env_file:
      - ./.env.database
  pgadmin:
    image: dpage/pgadmin4:latest
    ports:
      - 5454:5454/tcp
    environment:
      - PGADMIN_DEFAULT_EMAIL=<redacted>
      - PGADMIN_DEFAULT_PASSWORD=<redacted>
      - PGADMIN_LISTEN_PORT=5454
    depends_on:
      - database
volumes: 
  pgdata:

I would love to say "I found a few threads and tried what they recommend" but to be honest I don’t really understand them when I read them yet. The following threads might be related but they read like Latin to me.

"Error response from daemon: failed to create shim: OCI runtime create failed" error on Windows machine

Cannot start service api: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "python manage.py runserver

Cannot start service app: OCI runtime create failed: container_linux.go:349

Like, my guess from reading the error message is that there’s some sort of write permission I need to turn on, because the error message ends in "read-only file system: unknown". Sadly, that’s all I can contribute.

5

Answers


  1. Chosen as BEST ANSWER

    A coworker solved my issue.

    FROM node:16-alpine
    ENV NODE_ENV="development"
    WORKDIR /app
    COPY package.json .
    COPY package-lock.json .
    ARG NODE_ENV
    RUN apk add g++ make py3-pip
    RUN npm install
    RUN chown -R node /app/node_modules
    RUN npm install -g ts-node nodemon
    COPY . ./
    ENV PORT 8000
    EXPOSE $PORT
    CMD ["ts-node", "./src/server.ts"]
    
    

    I added RUN chown -R node /app/node_modules and it worked. He said the issue was Linux specific.


  2. Quite elementary good sir (Sherlock)…

    Linux is just picky when it comes to executing files as an executable (redundant I know).

    So you create a text file (or binary file) with commands but you want to then run that file and have it perform some job within the container, yet you will need to let the environment know that it has permissions to do so.

    chown or chmod would do the trick.

    –chmod– approch
    RUN chmod +x ./src/server.ts

    The level of permissions (+x for all) gives the executable the rights to do so within the container.

    Login or Signup to reply.
  3. In my case, docker compose had timed out, and had corrupted the containers. I just had to:

    1. increase the compose timeout (COMPOSE_HTTP_TIMEOUT=480)
    2. clean the containers (docker (image|container|network) prune
    3. run compose again
    Login or Signup to reply.
  4. In my case, I forgot to add npm i -g nodemon as I was working with multiple services.

    Login or Signup to reply.
  5. In my case it was with docker compose and starting containers and I just recreated them.

    docker-compose down
    docker-compose up -d
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search