Error occurs while trying to run n8n project

Describe the problem/error/question

Hello, I forked n8n project and build it but when trying to run it afterwards with docker I get an error
Note: When I build and run it with only pnpm (pnpm build & pnpm start) it works, only when doing it with docker I have this error

What is the error message (if any)?

/docker-entrypoint.sh: exec: line 14: n8n: not found

Please share your

I haven’t done changes on the mentioned file:

#!/bin/sh
if [ -d /opt/custom-certificates ]; then
  echo "Trusting custom certificates from /opt/custom-certificates."
  export NODE_OPTIONS="--use-openssl-ca $NODE_OPTIONS"
  export SSL_CERT_DIR=/opt/custom-certificates
  c_rehash /opt/custom-certificates
fi

if [ "$#" -gt 0 ]; then
  # Got started with arguments
  exec n8n "$@"
else
  # Got started without arguments
  exec n8n
fi

Not many changes in the Dockerfile:

ARG NODE_VERSION=22
ARG N8N_VERSION=snapshot
ARG LAUNCHER_VERSION=1.1.3
ARG TARGETPLATFORM

# ==============================================================================
# STAGE 1: System Dependencies & Base Setup
# ==============================================================================
FROM n8nio/base:${NODE_VERSION} AS system-deps

# ==============================================================================
# STAGE 2: Application Artifact Processor
# ==============================================================================
FROM alpine:3.22.0 AS app-artifact-processor

COPY ./compiled /app/

# ==============================================================================
# STAGE 3: Task Runner Launcher
# ==============================================================================
FROM alpine:3.22.0 AS launcher-downloader

RUN apk add --no-cache ca-certificates wget tar coreutils

ARG TARGETPLATFORM
ARG LAUNCHER_VERSION

RUN set -e; \
    # Fallback for TARGETPLATFORM
    if [ -z "$TARGETPLATFORM" ]; then \
      case "$(uname -m)" in \
        x86_64)  TARGETPLATFORM="linux/amd64" ;; \
        aarch64) TARGETPLATFORM="linux/arm64" ;; \
        *) echo "Unsupported machine: $(uname -m)"; exit 1 ;; \
      esac; \
    fi; \
    case "$TARGETPLATFORM" in \
      "linux/amd64") ARCH_NAME="amd64" ;; \
      "linux/arm64") ARCH_NAME="arm64" ;; \
      *) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
    esac; \
    mkdir /launcher-temp && cd /launcher-temp; \
    wget -q "https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz"; \
    wget -q "https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256"; \
    echo "$(cat task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256) task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz" > checksum.sha256; \
    sha256sum -c checksum.sha256; \
    mkdir -p /launcher-bin; \
    tar xzf task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz -C /launcher-bin; \
    cd / && rm -rf /launcher-temp

# ==============================================================================
# STAGE 4: Final Runtime Image
# ==============================================================================
FROM system-deps AS runtime

ARG N8N_VERSION
ARG N8N_RELEASE_TYPE=dev
ENV NODE_ENV=production
ENV N8N_RELEASE_TYPE=${N8N_RELEASE_TYPE}
ENV NODE_ICU_DATA=/usr/local/lib/node_modules/full-icu
ENV SHELL=/bin/sh

WORKDIR /home/node

COPY --from=app-artifact-processor /app /usr/local/lib/node_modules/n8n
COPY --from=launcher-downloader /launcher-bin/* /usr/local/bin/
COPY docker/images/n8n/docker-entrypoint.sh /
COPY docker/images/n8n/n8n-task-runners.json /etc/n8n-task-runners.json

RUN cd /usr/local/lib/node_modules/n8n && \
		npm rebuild sqlite3 && \
		ln -s /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \
    mkdir -p /home/node/.n8n && \
    chown -R node:node /home/node

# Copy Custom Nodes
# COPY docker/images/n8n-custom/custom-nodes/dist /home/node/.n8n/custom
# # Ensure proper permissions for the custom nodes
# RUN chown -R node:node /home/node/.n8n/custom


# Install [email protected] to fix brace-expansion vulnerability, remove after vulnerability is fixed in node image
RUN npm install -g [email protected]
RUN if [ -d "/usr/local/lib/node_modules/n8n/node_modules/pdfjs-dist" ]; then \
      cd /usr/local/lib/node_modules/n8n/node_modules/pdfjs-dist && npm install @napi-rs/canvas; \
    else \
      echo "pdfjs-dist not found, skipping canvas install"; \
    fi

EXPOSE 5678/tcp
USER node
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

LABEL org.opencontainers.image.title="n8n" \
      org.opencontainers.image.description="Workflow Automation Tool" \
      org.opencontainers.image.source="https://github.com/n8n-io/n8n" \
      org.opencontainers.image.url="https://n8n.io" \
      org.opencontainers.image.version=${N8N_VERSION}

Got started with arguments

docker build -t n8n-custom -f docker/images/n8n/Dockerfile .       
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n n8n-custom

Information on your n8n setup

  • n8n version: 1.108.0
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Error when running via docker
  • Operating system: mac

What I would do is run:

pnpm build:docker

Then try this from the docs:

docker volume create n8n_data

docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e GENERIC_TIMEZONE="<YOUR_TIMEZONE>" \
 -e TZ="<YOUR_TIMEZONE>" \
 -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
 -e N8N_RUNNERS_ENABLED=true \
 -v n8n_data:/home/node/.n8n \
 YOUR_IMAGE_NAME

If this doesn’t work I would then revert the docker file to default and try the same once more. This currently works for me with unmodified file, but modifying some things will break it.

Let me know if this helps,

Thank you very much!

No worries, let me know if you need more help or mark my previous reply as Solution if it did the trick :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.