Docker-compose doesn't accept environment variables with dot symbol (".")
Serg675 opened this issue · 12 comments
Hello,
The docker-compose (Docker Desktop for Windows) throws error and quits if environment variable contains dot symbol (".").
The error in "unexpected character "." in variable name near ..."
Don't know if it's new issue or not since haven't used docker-compose before.
Below is versioning information.
Client:
Cloud integration: 1.0.17
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:58:50 2021
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:52:31 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Docker Compose version v2.0.0
See also #8507
Same problem. It's currently impossible to set a variable with an IP address in .env
file.
Related commit:
https://github.com/compose-spec/godotenv/blob/655269e2565760ac457e473904300398c6150d47/parser.go#L113
If the variable name contains a dot in the env_file key file, this will cause an error in docker-compose 2.x. If the same variable is below environment key, it works.
This worked perfectly fine under 1.29.x, please reset it. Why does docker-compose need to handle this? Why doesn't the container shell do this?
I have the same problem!
Since updating to Docker Compose version 2.2.3 I'm not able to build containers where a service includes env_file's containing "." in the environment variable names:
docker-compose.yml
version: '3.7'
services:
app:
build:
context: .
dockerfile: Dockerfile.development
env_file:
- environment.yml
environment.yml
fpm.global.process_control_timeout=5m
docker-compose build app
Results in:
unexpected character "." in variable name near "fpm.global.process_control_timeout=5m\n"
Same problem here, using a legacy beast that can't be changed.
Docker compose all 2.x versions is affected.
same problem
I'm happy to open a PR for this, looks like someone just needs to add '.' to this switch case.
@Serg675 did you manage to find a workaround for this? the godotenv repo doesn't accept any pull requests.
@vivek-rao-1985
You can set environment variable with dot it the compose YAML file itself in the "environment:" section. It's accepted there. It doesn't work if to do it in outside file "env_file:"
Docker-compose 2.6.0 is affected.
ping: @glours @ulyssessouza @maxcleme
Yes we know, we didn't had time to add this one to the latest release, will try to include it in the next one and will ping you when it will be available in the v2
branch