Issue migrating to docker 1.x with worker

Hello all,

I try to migrate my 0.x version to 1.x but i’m facing issue as it does not start well.

My current docker-compose is :

version: '3.1'

services:
  postgres:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB
      - POSTGRES_NON_ROOT_USER
      - POSTGRES_NON_ROOT_PASSWORD
    ports:
      - 5432:5432
    volumes:
      - /home/admin/docker/n8n/init-data.sh:/docker-entrypoint-initdb.d/init-data.sh

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - GENERIC_TIMEZONE=Europe/Paris
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=168
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=n8n_redis
      - QUEUE_BULL_REDIS_PORT=6379
      - N8N_ENCRYPTION_KEY=ZZZZZZ
    ports:
      - 5678:5678
    links:
      - postgres
      - redis
      - n8n_worker
    volumes:
      - /home/admin/docker/n8n/data:/home/node/.n8n
    # Wait 5 seconds to start n8n to make sure that PostgreSQL is ready
    # when n8n tries to connect to it
    command: /bin/sh -c "sleep 5; n8n start"

  n8n_worker:
    image: docker.n8n.io/n8nio/n8n
    command: n8n worker
    restart: always
    environment:
      # ----- redis ----- #
      - QUEUE_BULL_REDIS_HOST=n8n_redis
      - QUEUE_BULL_REDIS_PORT=6379
      # ----- postgres ----- #
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
      - N8N_ENCRYPTION_KEY=ZZZZZZ
    ports:
      - 5676:5678
    links:
      - postgres
      - redis

  redis:
    container_name: n8n_redis
    image: redis:latest
    restart: always
    ports:
      - 6379:6379

After upgrading images, i have 2 containers not starting anymore
1st one has this error

 ›   Error: command /bin/sh not found

2nd one this error

 ›   Error: command n8n not found

If i remove the “command” line from docker-compose file, the 1st one start, then it asks to create a user if I connect to the N8N URL, but the second one still does not start with same error :

 ›   Error: command n8n not found

@Jon , I saw in another post you found the solution for a similar issue, any suggestion ?

Thanks a lot

Hey @mcc37,

Looks like you need to update yoru compose file, I would start by removing the command from the main n8n image and rather than waiting for 5 seconds use health checks. For the n8n_worker change the command to just worker.

You can find an updated compose example with Postgres and a Worker instance here: https://github.com/n8n-io/n8n/tree/master/docker/compose/withPostgresAndWorker

1 Like

Thanks a lot @Jon, I have modified the 2 commands line and now it works fine for a few minutes. I also had to clear the queue of executions, as it was full of executions pending. Pruning at 1h in compose did the job. I keep monitoring, but it sounds good.

Il will look after health check when I will have some more time.

Thanks a lot for your help !!

1 Like

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