# Instalação N8N docker com worker

Link: [https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose)

git clone [https://github.com/n8n-io/n8n-hosting.git](https://github.com/n8n-io/n8n-hosting.git)

Download: [https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgresAndWorker](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgresAndWorker)

<div data-hpc="true" id="bkmrk-name-last-commit-mes" style="text-align: justify;"><table aria-labelledby="folders-and-files" class="Table-module__Box--h4W6R DirectoryContent-module__Table--DNJx9" style="width: 107.737%;"><thead class="Table-module__Box_1--JrPYF"><tr class="Table-module__Box_2--kJgvd"><th class="DirectoryContent-module__Box_1--mB8B7" colspan="1" style="width: 35.0287%;"><span class="text-bold">Name</span></th><th class="hide-sm" style="width: 44.1132%;"><div class="Truncate__StyledTruncate-sc-23o1d2-0 liVpTx width-fit" title="Last commit message"><span class="text-bold">Last commit message</span></div></th><th class="DirectoryContent-module__Box_2--LsXd4" colspan="1" style="width: 20.8582%;"><div class="Truncate__StyledTruncate-sc-23o1d2-0 liVpTx width-fit" title="Last commit date"><span class="text-bold">Last commit date</span></div></th></tr></thead><tbody><tr class="Table-module__Box_3--SP5mx" id="bkmrk-parent-directory-.."><td class="f5 text-normal px-3" colspan="3" style="width: 100%;">### parent directory

[<div class="width-full DirectoryRow-module__Box--NOziH"><svg aria-hidden="true" class="octicon octicon-file-directory-fill Octicon-sc-9kayk9-0 DirectoryRow-module__Octicon--S5rCK" display="inline-block" fill="currentColor" focusable="false" height="16" overflow="visible" viewbox="0 0 16 16" width="16"><path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg>..</div>](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose)</td></tr><tr class="react-directory-row undefined" id="bkmrk-.env-add-encryption-"><td class="react-directory-row-name-cell-large-screen" colspan="1" style="width: 35.0287%;"><div class="react-directory-filename-column"><svg aria-hidden="true" class="octicon octicon-file color-fg-muted" display="inline-block" fill="currentColor" focusable="false" height="16" overflow="visible" viewbox="0 0 16 16" width="16"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate">[.env](https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgresAndWorker/.env ".env")</div></div></div></div></td><td class="react-directory-row-commit-cell" style="width: 44.1132%;"><div><div class="react-directory-commit-message">[add encryption key env variable](https://github.com/n8n-io/n8n-hosting/commit/a2e303b611ad00071588b43331fed96276c62834 "add encryption key env variable")</div></div></td><td style="width: 20.8582%;"><div class="react-directory-commit-age">8 months ago</div></td></tr><tr class="react-directory-row undefined" id="bkmrk-readme.md-import-doc"><td class="react-directory-row-name-cell-large-screen" colspan="1" style="width: 35.0287%;"><div class="react-directory-filename-column"><svg aria-hidden="true" class="octicon octicon-file color-fg-muted" display="inline-block" fill="currentColor" focusable="false" height="16" overflow="visible" viewbox="0 0 16 16" width="16"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate">[README.md](https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgresAndWorker/README.md "README.md")</div></div></div></div></td><td class="react-directory-row-commit-cell" style="width: 44.1132%;"><div><div class="react-directory-commit-message">[import docker-compose examples from n8n-io/n8n](https://github.com/n8n-io/n8n-hosting/commit/4ea03df539c125b04471030e0e2b735b63d2566e "import docker-compose examples from n8n-io/n8n")</div></div></td><td style="width: 20.8582%;"><div class="react-directory-commit-age">last year</div></td></tr><tr class="react-directory-row undefined" id="bkmrk-docker-compose.yml-a"><td class="react-directory-row-name-cell-large-screen" colspan="1" style="width: 35.0287%;"><div class="react-directory-filename-column"><svg aria-hidden="true" class="octicon octicon-file color-fg-muted" display="inline-block" fill="currentColor" focusable="false" height="16" overflow="visible" viewbox="0 0 16 16" width="16"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate">[docker-compose.yml](https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgresAndWorker/docker-compose.yml "docker-compose.yml")</div></div></div></div></td><td class="react-directory-row-commit-cell" style="width: 44.1132%;"><div><div class="react-directory-commit-message">[add encryption key env variable](https://github.com/n8n-io/n8n-hosting/commit/a2e303b611ad00071588b43331fed96276c62834 "add encryption key env variable")</div></div></td><td style="width: 20.8582%;"><div class="react-directory-commit-age">8 months ago</div></td></tr><tr class="react-directory-row undefined" id="bkmrk-init-data.sh-import-"><td class="react-directory-row-name-cell-large-screen" colspan="1" style="width: 35.0287%;"><div class="react-directory-filename-column"><svg aria-hidden="true" class="octicon octicon-file color-fg-muted" display="inline-block" fill="currentColor" focusable="false" height="16" overflow="visible" viewbox="0 0 16 16" width="16"><path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg><div class="overflow-hidden"><div class="react-directory-filename-cell"><div class="react-directory-truncate">[init-data.sh](https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgresAndWorker/init-data.sh "init-data.sh")</div></div></div></div></td><td class="react-directory-row-commit-cell" style="width: 44.1132%;"><div><div class="react-directory-commit-message">[import docker-compose examples from n8n-io/n8n](https://github.com/n8n-io/n8n-hosting/commit/4ea03df539c125b04471030e0e2b735b63d2566e "import docker-compose examples from n8n-io/n8n")</div></div></td><td style="width: 20.8582%;"><div class="react-directory-commit-age">last year</div></td></tr></tbody></table>

</div>## n8n with PostgreSQL and Worker

<div class="Box-sc-g0xbh4-0 kkSYPE" id="bkmrk-starts-n8n-with-post"><div class="Box-sc-g0xbh4-0 kxneWi" id="bkmrk-starts-n8n-with-post-1"><div class="Box-sc-g0xbh4-0 js-snippet-clipboard-copy-unpositioned DirectoryRichtextContent-module__SharedMarkdownContent--YORdJ" data-hpc="true"><article class="markdown-body entry-content container-lg"><div class="markdown-heading" dir="auto" style="text-align: justify;">[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgresAndWorker#n8n-with-postgresql-and-worker)</div>Starts n8n with PostgreSQL as database, and the Worker as a separate container.

## Start

<div class="markdown-heading" dir="auto" style="text-align: justify;">[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgresAndWorker#start)</div>To start n8n simply start docker-compose by executing the following command in the current folder.

**IMPORTANT:** But before you do that change the default users and passwords in the [`.env`](https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgresAndWorker/.env) file!

```
docker-compose up -d
```

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" style="text-align: justify;"><div class="zeroclipboard-container"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></div></div>To stop it execute:

```
docker-compose stop
```

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" style="text-align: justify;"><div class="zeroclipboard-container"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></div></div>## Configuration

<div class="markdown-heading" dir="auto" style="text-align: justify;">[<svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>](https://github.com/n8n-io/n8n-hosting/tree/main/docker-compose/withPostgresAndWorker#configuration)</div>The default name of the database, user and password for PostgreSQL can be changed in the [`.env`](https://github.com/n8n-io/n8n-hosting/blob/main/docker-compose/withPostgresAndWorker/.env) file in the current directory.

</article></div></div></div>