Skip to content

I fail in step 10 Run the following command to start your application. #22054

Closed
@minhsu12113

Description

@minhsu12113

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

I can't find what I'm looking for

Description

My Docker File

ARG NODE_VERSION=22.13.1
FROM node:${NODE_VERSION}-alpine
ENV NODE_ENV production 
WORKDIR /usr/src/app

RUN --mount=type=bind,source=package.json,target=package.json \
    --mount=type=bind,source=package-lock.json,target=package-lock.json \
    --mount=type=cache,target=/root/.npm \
    npm ci --omit=dev

USER node
EXPOSE 3000
CMD node src/index.js

My Compose File

services:
  server:
    build:
      context: .
    environment:
      NODE_ENV: production
      POSTGRES_HOST: db
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD_FILE: /run/secrets/db-password
      POSTGRES_DB: example
    ports:
      - 3000:3000 
    depends_on:
      db:
        condition: service_healthy
    secrets:
      - db-password
  db:
    image: postgres
    restart: always
    user: postgres
    secrets:
      - db-password
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=example
      - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
    expose:
      - 5432
    healthcheck:
      test: ["CMD", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  db-data:
secrets:
  db-password:
    file: db/password.txt

My Project Struct

Image

When I run command docker compose up --build I get error as the below, I felt something wrong when docker try to mount or read something from db directory but how to fix it?

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/run/desktop/mnt/host/e/Codes/docker-practice/docker-nodejs-sample/db/password.txt" to rootfs at "/run/secrets/db-password": mount /run/desktop/mnt/host/e/Codes/docker-practice/docker-nodejs-sample/db/password.txt:/run/secrets/db-password (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

Location

https://docs.docker.com/guides/nodejs/develop/

Suggestion

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions