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!