Giter Site home page Giter Site logo

Comments (5)

itzg avatar itzg commented on August 27, 2024

The variable name prefix is important:

https://docker-minecraft-server.readthedocs.io/en/latest/configuration/interpolating/#replacing-variables-inside-configs:~:text=You%20can%20also%20change%20REPLACE_ENV_VARIABLE_PREFIX%2C%20which%20defaults%20to%20%22CFG_%22%2C%20to%20limit%20which%20environment%20variables%20are%20allowed%20to%20be%20used.

By default, for security reasons, it will only access variables that have a name that starts with "CFG_".

from docker-minecraft-server.

janerjak avatar janerjak commented on August 27, 2024

I have to apologize for missing that crucial line in the wiki. That explains my struggles, thanks! Changing REPLACE_ENV_VARIABLE_PREFIX to _ and prefixing every variable worked perfectly. Although curly braces as in ${VAR_NAME} seem to be required as stated in the wiki ($VAR_NAME does not work).

If I understand the good intention behind the required prefix correctly - somebody could push a malicious mod / plugin update that scans for secrets in environment variables and steal them otherwise?

Is that the reason you can not disable this? Setting REPLACE_ENV_VARIABLE_PREFIX to the empty string doesn't seem to work.

from docker-minecraft-server.

itzg avatar itzg commented on August 27, 2024

I have to apologize for missing that crucial line in the wiki. That explains my struggles, thanks! Changing REPLACE_ENV_VARIABLE_PREFIX to _ and prefixing every variable worked perfectly. Although curly braces as in ${VAR_NAME} seem to be required as stated in the wiki ($VAR_NAME does not work).

If I understand the good intention behind the required prefix correctly - somebody could push a malicious mod / plugin update that scans for secrets in environment variables and steal them otherwise?

Correct.

Is that the reason you can not disable this? Setting REPLACE_ENV_VARIABLE_PREFIX to the empty string doesn't seem to work.

I just tested and setting to empty string disables the prefix as documented:

I created a config/test.cfg file that contained

eula=${EULA}

and used the compose file

services:
  mc:
    image: itzg/minecraft-server
    environment:
      REPLACE_ENV_VARIABLE_PREFIX: ""
      EULA: true
    volumes:
      - ./config:/config
      - ./data:/data

and the file data/config/test.cfg now contains

eula=true

from docker-minecraft-server.

janerjak avatar janerjak commented on August 27, 2024

I have to correct, that works exactly as expected.

Is that the reason you can not disable this? Setting REPLACE_ENV_VARIABLE_PREFIX to the empty string doesn't seem to work.

Before writing this I tested it with my setup multiple times to no avail - but now it works fine.
The only thing I can assume is that there were external factors like Portainer not correctly mapping my stack environment variables. I assume this because the only variables not replaced in my test.cfg are those that have no value. Maybe that was the issue.

Nevertheless, this is resolved for me. I'm still baffled. Sorry for wasting your time.

from docker-minecraft-server.

janerjak avatar janerjak commented on August 27, 2024

Closing this issue. I made some mistake somewhere.

REPLACE_ENV_VARIABLE_PREFIX decides which variables are replaced. The default value is CFG_ meaning only variables like CFG_VAR_1 are replaced. Setting REPLACE_ENV_VARIABLE_PREFIX to the empty string makes docker-minecraft-server replace every variable.

from docker-minecraft-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.