portainer: Unable to specify environment variables with a comma in them when deploying from Git with relative path volumes enabled
Before you start please confirm the following.
- Yes, I’ve searched similar issues on GitHub.
- Yes, I’ve checked whether this issue is covered in the Portainer documentation or knowledge base.
Problem Description
Setting an environment variable for my stack using the Portainer UI to a value with a comma in it causes the stack deployment to fail. This only occurs when deploying a stack from a Git repository and when the Relative path volumes option is enabled.
Expected Behavior
The environment variable value to be handled correctly and the container to start
Actual Behavior
The deploy fails with the following error:
an error occurred while running unpacker container with exit code 255: panic: runtime error: index out of range [1] with length 1 goroutine 1 [running]: github.com/compose-spec/compose-go/cli.getAsEqualsMap({0xc0004b8480, 0x8, 0x0}) github.com/compose-spec/compose-go@v1.2.5/cli/options.go:419 +0x10c github.com/compose-spec/compose-go/cli.WithOsEnv(0xc000490070) github.com/compose-spec/compose-go@v1.2.5/cli/options.go:172 +0x38 github.com/compose-spec/compose-go/cli.NewProjectOptions({0xc00041c110, 0x1, 0x1}, {0xc00010c240, 0x8, 0x0}) github.com/compose-spec/compose-go@v1.2.5/cli/options.go:55 +0xd0 github.com/docker/compose/v2/cmd/compose.(*projectOptions).toProjectOptions(0xc00009f300, {0xc00063fa78, 0x1, 0x1}) github.com/docker/compose/v2/cmd/compose/compose.go:213 +0x21f github.com/docker/compose/v2/cmd/compose.(*projectOptions).toProject(0xc00009f300, {0xc0002e01e0, 0x10000c00063fab8, 0x2}, {0xc00063fa78, 0x18, 0x7f49655af108}) github.com/docker/compose/v2/cmd/compose/compose.go:156 +0x5f github.com/docker/compose/v2/cmd/compose.(*projectOptions).WithServices.func1({0x1451b20, 0xc00010c000}, {0xc0002e01e0, 0x0, 0x2}) github.com/docker/compose/v2/cmd/compose/compose.go:118 +0x98 github.com/docker/compose/v2/cmd/compose.Adapt.func1({0x1451b20, 0xc00010c000}, 0x2, {0xc0002e01e0, 0x1, 0xc00063fb20}) github.com/docker/compose/v2/cmd/compose/compose.go:88 +0x36 github.com/docker/compose/v2/cmd/compose.AdaptCmd.func1(0xc0003d7900, {0xc0002e01e0, 0x0, 0x2}) github.com/docker/compose/v2/cmd/compose/compose.go:67 +0x223 github.com/spf13/cobra.(*Command).execute(0xc0003d7900, {0xc0004b8160, 0x2, 0x2}) github.com/spf13/cobra@v1.4.0/command.go:856 +0x60e github.com/spf13/cobra.(*Command).ExecuteC(0xc000020000) github.com/spf13/cobra@v1.4.0/command.go:974 +0x3bc github.com/spf13/cobra.(*Command).Execute(...) github.com/spf13/cobra@v1.4.0/command.go:902 github.com/docker/cli/cli-plugins/plugin.RunPlugin(0x8, 0xc0003d7680, {{0x1275131, 0x5}, {0x127ca73, 0xb}, {0x14169f8, 0x6}, {0x0, 0x0}, ...}) github.com/docker/cli@v20.10.12+incompatible/cli-plugins/plugin/plugin.go:51 +0x130 github.com/docker/cli/cli-plugins/plugin.Run(0x12f8be0, {{0x1275131, 0x5}, {0x127ca73, 0xb}, {0x14169f8, 0x6}, {0x0, 0x0}, {0x0, ...}, ...}) github.com/docker/cli@v20.10.12+incompatible/cli-plugins/plugin/plugin.go:64 +0xee main.pluginMain() github.com/docker/compose/v2/cmd/main.go:36 +0xdf main.main() github.com/docker/compose/v2/cmd/main.go:69 +0x1aa
Steps to Reproduce
- Create a docker-compose file for your stack and use the docker environment variable override format to provide a default value:
environment:
- WHITELISTED_DOMAINS=${WHITELISTED_DOMAINS-https://www.contoso.com}
- In the Portainer UI for the stack override the environment variable to a string with a comma in it:
- Pull and redeploy the container
If you remove the comma from the string it will deploy fine.
Portainer logs or screenshots
No response
Portainer version
2.19.4
Portainer Edition
Business Edition (BE/EE) with 5NF / 3NF license
Platform and Version
24.0.7
OS and Architecture
Windows 11
Browser
Edge
What command did you use to deploy Portainer?
version: "3"
services:
portainer:
image: portainer/portainer-ee:latest
ports:
- 9443:9443
volumes:
- ./data:/data
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
Additional Information
No response
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (5 by maintainers)
If anyone needs to work around this during the meantime, I’ve managed to work around this by escaping a comma in my environment variable with a
\.