Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with docker env_file parsing #243

Closed
lalop opened this issue Aug 23, 2017 · 8 comments
Closed

Conflict with docker env_file parsing #243

lalop opened this issue Aug 23, 2017 · 8 comments

Comments

@lalop
Copy link

lalop commented Aug 23, 2017

Hello,

I'm working on an app using docker, my environment variables are stored in an env_file and loaded in the environment by docker.
I have variable that can contains space, if I don't escape it with quotes phpdotenv throw an exception. Since the variable is ever loaded I don't understand why phpdotenv want to validate it.

For exemple if I use a database's password with a space, I will add something like that in my env_file

...
MYSQL_PASSWORD=user pass
...

The mysql container will create a user with this password but phpdotenv will throw an error because it expects to see quotes around user pass but if I add this quotes the mysql user will be created with quotes in is password.

Note that, phpdotenv don't read the env_file, it gets the variables from environment.

@lalop
Copy link
Author

lalop commented Aug 23, 2017

In fact an .env file was in the project and the error come from this one.
So the error was just a conflict between docker's parser and the phpdotenv one

@timkelty
Copy link

timkelty commented Sep 7, 2017

Having the same problem.

@lalop Did you find a solution? Trying to figure out if this is a phpdotenv specific, or if it is all docker-compose?

docker/compose#2854

@lalop
Copy link
Author

lalop commented Sep 7, 2017

Not really

@andrewkandzuba
Copy link

Same issue happens to "dockerized" java command invocation upon passing external values to java cli via system property:

Dockerfile:

ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

Snippet from my docker-compose:

  ...
    environment:
      JAVA_OPTS: |
        -server
        -ea
        -Xms64m
        -Xmx128m
        -Dfoo.property=My Property
...

resulting with Error: Could not find or load main class Property

@gueroverde
Copy link

I think this is not a problem, docker is infrastructure level, and application level is another that should even be in separate directory (repositories) docker through the volumes you can link your application although this in another directory, well I think I.

@Arvi89
Copy link

Arvi89 commented Jan 22, 2018

No fix for this issue? This is quite annoying, as soon as the code uses load, it doesn't load the docker env variable (even if there is no .env file or it's an empty file).

@timkelty
Copy link

@Arvi89 it isn't a phpdotenv issue, it is a docker issue. AFAIK there is no solution yet: docker/compose#2854

@pgross41
Copy link

I have the same problem, this seems to be a direct conflict between how Docker parses and phpdotenv parses.

From the Docker docs: There is no special handling of quotation marks. This means that they are part of the VAL.

Per phpdotenv: Unquoted values cannot contain whitespace

This means there is no way for me to use variable with spaces in it (without having separate env files). My Docker image requires an environment variable (with whitespace) in order to run. If I use quotes, Docker reads it incorrectly. If I don't use quotes my PHP app blows up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants