External CLI tools in n8n

Hey guys!

I am getting back to working with n8n and I really have fun doing so. My problem is I have very limited Docker experience. I managed to get my container running and it is proxied with NGINX to serve via HTTPS.

I am getting to more complex use cases. A lot of my use cases involve XML processing. Back in November 2019 I allready opened this topic: XSLT/XSD processor or command line tool

Now I want to dig deeper into this. I would like to have some more command line tools available inside of the docker container. For example I would like to have xmllint so that I can lint/validate incoming XML against it. Also some XSLT processing would be good so that I can use one XML file and anXSLT translation file to map it to something different. Right now I use the Set Node for this and well it get’s the job done. But XSLT is much more portable than javascript dot notation object manipulation.

So my question is: how can I put external tools into my docker image. I use this very minimal docker-compose.yml to serve the container and make it work with the nginx reverse proxy:

version: "3"

    image: n8nio/n8n
    restart: always
      - "5678:5678"
      - N8N_BASIC_AUTH_ACTIVE=false
      - N8N_HOST=our.domain.tld
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_TUNNEL_URL=https://our.domain.tld/
      - /var/run/docker.sock:/var/run/docker.sock
      - ./.n8n:/home/node/.n8n

Is it possible to use a docker-compose.yml or something to tell the image to apt-get install some packages? I then could use those via the Execute Command node.

Or is it possible to add npm packages to the image? so I can require them in a funciton node?

Regards Sebastian

@vuchl Hi, i recently figured this out as well, how to use external npm packages, with help from @jan.

This is how i implement it now:

1.Create Dockerfile in the same folder as your docker-compose.yml

Dockerfile content:

FROM n8nio/n8n

RUN npm install -g he
RUN npm install -g uuid
RUN npm install -g object-deep-compare
RUN npm install -g validator
RUN npm install -g gm
RUN npm install -g node-qpdf
RUN npm install -g dayjs
RUN npm install -g generate-unique-id

2.Build the docker image with this command:

docker build -t n8np .

^ ‘n8np’ is a chosen name…could be anything. Don’t forget the ’ . ’ at the end (i did).

3.Modify in docker-compose.yml :

    image: n8np

4.Modify in .env :


5.That’s it. You can start your docker containers now with:

docker-compose up -d

And everytime you need to upgrade n8n to a newer version:

docker pull n8nio/n8n
docker build -t n8np .
docker-compose stop
docker-compose rm
docker-compose up -d

Dude! This is exactly what I needed! Thanks a bunch for helping out so quick

1 Like

Thanks a lot for sharing and helping out @shrey-42!

1 Like

Thanks, cheers!

This is really helpful. Thanks for that.
I tried to also put in the node n8n-nodes-dnc-suitecrm.
Therefor i added the line:

RUN npm install n8n-nodes-dnc-suitecrm

But it threw an error.
Then I triede to add the dependencies before like so:

RUN apk --no-cache --virtual build-dependencies add \ python \ make \ g++ \ && npm i n8n-nodes-dnc-suitecrm --unsafe-perm \ && apk del build-dependencies`

I took this line from @svenjanssen 's thread on how to install the suite-crm node.
but it gives me an error during the build process.

Does anyone know how to solve this?

1 Like

What error do you get?

Also maybe split the RUN commands in separate lines for apk and npmto see where the error actually occurs.

Also make sure you npm install in the correct directory as mentioned her: https://www.npmjs.com/package/n8n-nodes-dnc-suitecrm (“nstall it to the n8n root folder”)

it works now.
But I didn’t manage to put everything in the Dockerfile.
As soon as the Container is up and running I could enter it then added python, make and g++ with separate commands

apk add python
apk add make
apk add g++

and then i could install the suitecrm node with this command:


then exit the container again and restart it with

docker restart containername

Well yes but after stopping and starting the container, the changes will be gone since they are only in the RAM.

You need to adjust your Dockerfile if you want to have persistent additional software inside of the image.

1 Like

Yes you are right.
I tried to put the lines into the Dockerfile but it didn’t work.
Any ideas why this could happen?

I still can’t put it in the Dockerfile. It gives me the Warning:

npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142

therefore it can be installed and the module appears in n8n but I can’t do anything with it.
It doesn’t fetch or send something.

So I digged deeper to find the problem.

It seems that without the package.json file it doesn’t get the permissions or something to work.

How can I get the package.json file also into the Container?
Does someone know what to do here?

I don’t think I am the only person with this sort of problem. Aren’t there a lot of custom nodes with similar dependencies and needs?

I appreciate any ideas/help

Can you please post your Dockerfile?


Now it works. I needed to install peer dependencies on my own. So I added this to the end of the Dockerfile as well. The build works without errors.
This is what my dockerfile looks like now:

FROM n8nio/n8n

RUN apk --update add python
RUN apk --update add make
RUN apk --update add g++
RUN npm install -g n8n-nodes-suitecrm --unsafe
RUN npm install -g install-peerdeps

thank you so much for your help and input!