[GH-ISSUE #4212] Variable substitution for TOML config in Docker Compose - how to make it happen? #3316

Closed
opened 2026-05-05 14:08:22 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @Kenya-West on GitHub (May 11, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/4212

Bug Description

I try to substitute variables set in frps.toml.template file for dockerized frps instance and make Docker to produce frps.toml file in mounted dir:

docker-compose.yml:

version: '3.8'
services:
  frps:
    image: snowdreamtech/frps
    container_name: frps
    restart: unless-stopped
    env_file:
      - .env
    volumes:
      - ./config-frps:/etc/frp # there lies frps.toml.template and should have been frps.toml
    network_mode: host

volumes:
  certs:
    external: true
    name: caddy_caddy-certs

.env:

DOMAIN=example.com      # your domain
FRP_CADDY_PATH=frp                      # must be present, or it produces bugs. Example value: `frps`
FRPS_SERVER_PORT=7000                   # port of the server
FRPS_AUTH_METHOD=token                  # authentication method
FRPS_AUTH_TOKEN=token                      # authentication token
FRPS_DASHBOARD_PORT=7500                # port of the dashboard (server)
FRPS_DASHBOARD_USER=admin           # frps dashboard username
FRPS_DASHBOARD_PASSWORD=admin          # frps dashboard password
FRPC_DASHBOARD_PORT=7400                # port of the dashboard (client)
FRPC_DASHBOARD_USER=admin           # frpc dashboard username
FRPC_DASHBOARD_PASSWORD=admin          # frpc dashboard password

config-frps/frps.toml.template

bindPort = ${FRPS_SERVER_PORT}
allowPorts = [
  { start = 22001, end = 22089 }
]
webServer.addr = "0.0.0.0"
webServer.port = ${FRPS_DASHBOARD_PORT}
webServer.user = "${FRPS_DASHBOARD_USER}"
webServer.password = "${FRPS_DASHBOARD_PASSWORD}"
auth.method = "${FRPS_AUTH_METHOD}"
auth.token = "${FRPS_AUTH_TOKEN}"

frps (or Docker itself) does not substitute variables and does not produce frps.toml file inside the container:

frps  | 2024-05-12T10:32:51.902635600Z open /etc/frp/frps.toml: no such file or directory

How to force Docker to create frps.toml file?

frpc Version

0.56.1

frps Version

0.56.1

System Architecture

linux/amd64

Configurations

Logs

Steps to reproduce

  1. Dockerize frps;
  2. Define variable in .env file;
  3. Set the variable as a value in frps.toml;
  4. docker compose up -d frps the instance;
  5. See that variable is not substituted.

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @Kenya-West on GitHub (May 11, 2024). Original GitHub issue: https://github.com/fatedier/frp/issues/4212 ### Bug Description I try to substitute variables set in `frps.toml.template` file for dockerized frps instance and make Docker to produce `frps.toml` file in mounted dir: **docker-compose.yml**: ```yaml version: '3.8' services: frps: image: snowdreamtech/frps container_name: frps restart: unless-stopped env_file: - .env volumes: - ./config-frps:/etc/frp # there lies frps.toml.template and should have been frps.toml network_mode: host volumes: certs: external: true name: caddy_caddy-certs ``` **.env**: ```dotenv DOMAIN=example.com # your domain FRP_CADDY_PATH=frp # must be present, or it produces bugs. Example value: `frps` FRPS_SERVER_PORT=7000 # port of the server FRPS_AUTH_METHOD=token # authentication method FRPS_AUTH_TOKEN=token # authentication token FRPS_DASHBOARD_PORT=7500 # port of the dashboard (server) FRPS_DASHBOARD_USER=admin # frps dashboard username FRPS_DASHBOARD_PASSWORD=admin # frps dashboard password FRPC_DASHBOARD_PORT=7400 # port of the dashboard (client) FRPC_DASHBOARD_USER=admin # frpc dashboard username FRPC_DASHBOARD_PASSWORD=admin # frpc dashboard password ``` config-frps/**frps.toml.template** ```toml bindPort = ${FRPS_SERVER_PORT} allowPorts = [ { start = 22001, end = 22089 } ] webServer.addr = "0.0.0.0" webServer.port = ${FRPS_DASHBOARD_PORT} webServer.user = "${FRPS_DASHBOARD_USER}" webServer.password = "${FRPS_DASHBOARD_PASSWORD}" auth.method = "${FRPS_AUTH_METHOD}" auth.token = "${FRPS_AUTH_TOKEN}" ``` `frps` (or Docker itself) does not substitute variables and does not produce `frps.toml` file inside the container: ```log frps | 2024-05-12T10:32:51.902635600Z open /etc/frp/frps.toml: no such file or directory ``` How to force Docker to create `frps.toml` file? ### frpc Version 0.56.1 ### frps Version 0.56.1 ### System Architecture linux/amd64 ### Configurations - ### Logs - ### Steps to reproduce 1. Dockerize `frps`; 2. Define variable in `.env` file; 3. Set the variable as a value in `frps.toml`; 4. `docker compose up -d frps` the instance; 5. See that variable is not substituted. ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [X] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@Kenya-West commented on GitHub (May 12, 2024):

Since I forgot to rename file from frps.toml to frps.toml.template and in result got other kind of error message, whole body of the question changed.

P. S. With NGINX, env substitution works. What's wrong with FRP?

<!-- gh-comment-id:2106203443 --> @Kenya-West commented on GitHub (May 12, 2024): Since I forgot to rename file from `frps.toml` to `frps.toml.template` and in result got other kind of error message, whole body of the question changed. P. S. With NGINX, env substitution works. What's wrong with FRP?
Author
Owner

@Kenya-West commented on GitHub (May 12, 2024):

UPD: Found out that environment variables substitution should be implemented on developer's side.

The tool envsubst should be in Docker's image and executed during image building process.

Which means I need to go directly to snowdreamtech/frp and post an issue there.

Sorry for posting irrelevant problem here. This issue can now be closed.

<!-- gh-comment-id:2106240776 --> @Kenya-West commented on GitHub (May 12, 2024): UPD: Found out that environment variables substitution should be implemented on developer's side. The tool `envsubst` should be in Docker's image and executed during image building process. Which means I need to go directly to [snowdreamtech/frp](https://github.com/snowdreamtech/frp) and post an issue there. Sorry for posting irrelevant problem here. This issue can now be closed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3316
No description provided.