Error while deploying custom image of n8n

Hii,
I am trying to deploy the n8n-custom local image I have created. I tried running docker-compose up and its giving me this error.

n8n-n8n-1 | [FATAL tini (7)] exec /docker-entrypoint.sh failed: Permission denied
n8n-traefik-1 | time=“2022-09-02T08:11:40Z” level=info msg=“Configuration loaded from flags.”

Can anyone help?

Hi @AnjanaSAcroUser, the custom image provided in our repo has been changed a lot recently, did you perhaps not implement all changes yet?

If you’re still having trouble after doing so, could you share your Dockerfile and docker-entrypoint.sh script?

yes @MutedJam
Dockerfile:-


# 1. Create an image to build n8n

FROM node:16-alpine as builder



# Update everything and install needed dependencies

USER root

# Install all needed dependencies

RUN apk --update add --virtual build-dependencies python3 build-base ca-certificates && \

npm_config_user=root npm install -g lerna run-script-os

WORKDIR /data

COPY lerna.json .

COPY package.json .

COPY packages/cli/ ./packages/cli/

COPY packages/core/ ./packages/core/

COPY packages/design-system/ ./packages/design-system/

COPY packages/editor-ui/ ./packages/editor-ui/

COPY packages/nodes-base/ ./packages/nodes-base/

COPY packages/workflow/ ./packages/workflow/

RUN rm -rf node_modules packages/*/node_modules packages/*/dist

RUN npm config set legacy-peer-deps true

RUN npm install --production --loglevel notice

RUN lerna bootstrap --hoist -- --production

RUN npm run build

# 2. Start with a new clean image with just the code that is needed to run n8n

FROM node:16-alpine

USER root

RUN apk add --update graphicsmagick tzdata tini su-exec git

WORKDIR /data

# Install all needed dependencies

RUN npm_config_user=root npm install -g full-icu

# Install fonts

RUN apk --no-cache add --virtual fonts msttcorefonts-installer fontconfig && \

update-ms-fonts && \

fc-cache -f && \

apk del fonts && \

find /usr/share/fonts/truetype/msttcorefonts/ -type l -exec unlink {} \;

ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu

COPY --from=builder /data ./

COPY docker/images/n8n-custom/docker-entrypoint.sh /docker-entrypoint.sh

ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

EXPOSE 5678/tcp

sh file:-

#!/bin/sh

if [ -d /root/.n8n ] ; then
  chmod o+rx /root
  chown -R node /root/.n8n
  ln -s /root/.n8n /home/node/
fi

chown -R node /home/node

if [ "$#" -gt 0 ]; then
  # Got started with arguments
  COMMAND=$1;

  if [[ "$COMMAND" == "n8n" ]]; then
    shift
    exec su-exec node ./packages/cli/bin/n8n "$@"
  else
    exec su-exec node "$@"
  fi

else
# Got started without arguments
exec su-exec node ./packages/cli/bin/n8n
fi

Can you update your Dockerfile to match the structure in the repo? It’s now copying the docker-entrypoint file into the working directory rather than the root one:

COPY docker/images/n8n-custom/docker-entrypoint.sh ./
(...)
ENTRYPOINT ["tini", "--", "./docker-entrypoint.sh"]

The script itself then starts n8n like so:

cd packages/cli; exec node ./bin/n8n

Hi @MutedJam/@marcus

N8N image is working fine with https and our ssl certificate.
But we are getting error while running the n8n custom image.
I am attaching the screenshot for reference.
Can you help us in this.

Thanks & Regards,
Abhilash

Hey @abhilash,

Looks like there might be a permission issue with the entrypoint script can you check the permissions for it and make sure it exists in the image?

1 Like

Hey @abhilash,
can you also make sure to build a new image using docker build --no-cache. I remember this happened to me once and I could fix it buy making sure I run a new build. Don’t know why it happened though.

3 Likes

Hii ,
Right now I am not able to build the custom image as well. Getting this error. And I am having the latest n8n code. Can anyone help?

@marcus @MutedJam can you please help us in the docker file. We are trying to build custom image. But we are getting this deprecated some packages error. It was working fine like we were able to build the image and not to run the docker-compose but now we are not able build the custom docker image with same code.

Hi @abhilash, could you share the exact error you are seeing please? Thank you!

Hi @MutedJam
Please find the attached screenshot for detailed error.

Thanks

Hi @abhilash, so you’re seeing the exact same error message as @AnjanaSAcroUser? ERR_SOCKET_TIMEOUT suggests a network problem, so you might need to look into this from your end.

Also, are you using the current master branch of the n8n repository? The Dockerfile has been updated very recently: n8n/docker/images/n8n-custom at master · n8n-io/n8n · GitHub. I’ve just tested this and after running npm install, the docker build command finished as expected:

Hi @MutedJam
Anjana and I are working together on this issue.
Yes we are using latest n8n dockerfile. 2-3 days back only we have take the recent code from n8n. Can you pls elaborate on network problem.

Hi @abhilash, as per your screenshot, this error suggests a problem related to network connectivity, perhaps because of a very restrictive firewall or proxy configuration. Are you also facing trouble building the image on a different network?

Hi @MutedJam
The machine I am working on don’t have any firewall restrictions. On same machine I was able to build the docker image few days back with the same code and let me verify for other environments.

Thanks

Hm, I am afraid I don’t know what could cause the problem then. Perhaps you can share your current dockerfile and docker entrypoint so I can give this a go on my end?

Dockerfile

# 1. Create an image to build n8n
FROM node:16-alpine as builder

# Update everything and install needed dependencies
USER root

# Install all needed dependencies
RUN apk --update add --virtual build-dependencies python3 build-base ca-certificates git && \
	npm_config_user=root npm install -g npm@latest run-script-os turbo

WORKDIR /data

COPY turbo.json .
COPY package.json .
COPY package-lock.json .
COPY packages/cli/ ./packages/cli/
COPY packages/core/ ./packages/core/
COPY packages/design-system/ ./packages/design-system/
COPY packages/editor-ui/ ./packages/editor-ui/
COPY packages/nodes-base/ ./packages/nodes-base/
COPY packages/workflow/ ./packages/workflow/
RUN rm -rf node_modules packages/*/node_modules packages/*/dist

RUN npm config set legacy-peer-deps true
RUN npm install --loglevel notice
RUN npm run build


# 2. Start with a new clean image with just the code that is needed to run n8n
FROM node:16-alpine

USER root

RUN apk add --update graphicsmagick tzdata tini su-exec git

WORKDIR /data

# Install all needed dependencies
RUN npm_config_user=root npm install -g npm@latest full-icu

# Install fonts
RUN apk --no-cache add --virtual fonts msttcorefonts-installer fontconfig && \
	update-ms-fonts && \
	fc-cache -f && \
	apk del fonts && \
	find  /usr/share/fonts/truetype/msttcorefonts/ -type l -exec unlink {} \;

ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu

COPY --from=builder /data ./

COPY docker/images/n8n-custom/docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

EXPOSE 5678/tcp

docker entrypoint

#!/bin/sh

if [ -d /root/.n8n ] ; then
  chmod o+rx /root
  chown -R node /root/.n8n
  ln -s /root/.n8n /home/node/
fi

chown -R node /home/node

if [ "$#" -gt 0 ]; then
  # Got started with arguments
  COMMAND=$1;

  if [[ "$COMMAND" == "n8n" ]]; then
    shift
    (cd packages/cli; exec su-exec node ./bin/n8n "$@")
  else
    exec su-exec node "$@"
  fi

else
# Got started without arguments
exec su-exec node ./packages/cli/bin/n8n
fi

Hi @abhilash, the Dockerfile provided by n8n has changed quite a bit. For example, it no longer uses the root user but the node user. The entrypoint file is executed from the working dir, not the root directory.

Could you update your own files using the files provided by n8n and give this another go?

Thanks @MutedJam
I will update the files again.

Hi @MutedJam
I have taken the recent code from n8n repo.
Still while building custom docker image I am getting error.
Attaching the screenshot of error.


Thanks,
Abhilash