How do I mount a persistent configuration file for `cloudflared` in a Docker container?

Question

Grade: Education Subject: Support
How do I mount a persistent configuration file for `cloudflared` in a Docker container?
Asked by:
87 Viewed 87 Answers

Answer (87)

Best Answer
(548)
To ensure your `cloudflared` configuration persists across container restarts, you should mount a volume. In your `docker-compose.yml` file, define a volume mount for the `/etc/cloudflared/config` directory (or the directory where you place your `config.yml` file). For example: `volumes: - ./config:/etc/cloudflared/config`. This maps the `./config` directory on your host machine to the `/etc/cloudflared/config` directory inside the container. If the `./config` directory doesn't exist, create it and place your `config.yml` file within it.