> For the complete documentation index, see [llms.txt](https://nginxle.onepub.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nginxle.onepub.dev/docker-compose.md).

# docker-compose

## Start with docker-compose

May users deploy their docker containers using docker-compose. In these circumstances using the Nginx-LE cli tools may not be appropriate.

This is the case for most production systems, in which case you will just use the standard docker management tools.

Whilst it can be useful to run `nginx-le config,` it is not required and for most users won't be needed.

If you want to use any of the nginx-le commands you MUST first run:

* `docker-compose up` at least once
* `nginx-le config`.

Note: If you do use `nginx-le config` then if you change your dock-compose configuration, docker-compose will recreate the container. When this occurs you MUST re-run `nginx-le config` and select the new container.

To start Nginx-LE with docker-compose you must provide a number of configuration settings:

The following is a sample configuration:

```
version: '3.3'
volumes:
  certificates:

services:   
  nginx-le:
    container_name: nginx-le
    image: noojee/nginx-le:latest
    restart: on-failure
    ports:
      - "80:80"
      - "443:443"
    network_mode: "host"
    environment: 
      HOSTNAME: www
      DOMAIN: example.com.au
      TLD: com.au
      DOMAIN_WILD_CARD: "false"
      PRODUCTION: "true"
      EMAIL_ADDRESS: support@example.com
      AUTO_ACQUIRE: "true"
      DEBUG: "true"
      AUTH_PROVIDER: cloudflare
      AUTH_PROVIDER_TOKEN: XXXXXXX
      AUTH_PROVIDER_EMAIL_ADDRESS: XXX@XXXXX
      SMTP_SERVER: smtp.someserver.com
      SMTP_SERVER_PORT: 25
    volumes:
      - certificates:/etc/letsencrypt
      - /opt/nginx/include:/etc/nginx/include
    logging:
      driver: "journald"
```

The environment variables for the Auth Provider will change based on which Auth Provider you have selected.

### Volumes

The `certificates` volume is used to store the certbot certificates between restarts. The `/opt/nginx/include` host path is where you place the nginx `.location` and `.upstream` includes.

#### Acquire a certificate

If you set the environment variable AUTO\_ACQUIRE=true then Nginx-LE will automatically acquire and renew certificates as required.

If you don't pass the AUTO\_ACQUIRE environment variable or set it to false than you must manually acquire a certificate (using nginx-le acquire).

{% hint style="info" %}
We strongly recommend using AUTO\_ACQUIRE and don't know of any valid reason why you would not.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://nginxle.onepub.dev/docker-compose.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
