Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Failure starting docker container. "failed to create shim task: OCI runtime create failed: runc create failed"

Ask Question

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.

    It was one of the Dockerfiles. A backend one. Sorry, can't find the actual change now in the repo; its been a while since I worked on the project. – plutownium Nov 2, 2022 at 15:10

    In my case, docker compose had timed out, and had corrupted the containers. I just had to:

  • increase the compose timeout (COMPOSE_HTTP_TIMEOUT=480)
  • clean the containers (docker (image|container|network) prune
  • run compose again
  • 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.

    In my case it was with docker compose and starting containers and I just recreated them.

    docker-compose down
    docker-compose up -d
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.