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

env_file not processing strings correctly using "docker compose" #11591

Closed
bunkiedc opened this issue Mar 8, 2024 · 4 comments
Closed

env_file not processing strings correctly using "docker compose" #11591

bunkiedc opened this issue Mar 8, 2024 · 4 comments

Comments

@bunkiedc
Copy link

bunkiedc commented Mar 8, 2024

Description

Using this notation with in my .yaml file via docker compose:

service:
  serviceName:
    env_file:
      - config/config.env

Worked with previous version, but not with v2.24.7

I also tested with docker-compose and it works correctly.

I've tried to change it to a few different ways, including using:

  - path: config/config.env
    required: true

and adding quotes etc... nothing is working.

Steps To Reproduce

just use an env_file: via compose.
docker compose --env-file stack.env -f container.yaml config | docker stack deploy container_name --with-registry-auth --compose-file -

Error returned:
services.serviceName.env_file.0 must be a string

Compose Version

Docker Compose version v2.24.7

docker-compose version 1.28.5, build c4eb3a1f
docker-py version: 4.4.4
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Docker Environment

lient: Docker Engine - Community
 Version:    25.0.4
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.7
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.23.0
    Path:     /usr/libexec/docker/cli-plugins/docker-scan

Server:
 Containers: 15
  Running: 14
  Paused: 0
  Stopped: 1
 Images: 40
 Server Version: 25.0.4
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: active
  NodeID: lqxmo7qozkk3336shyyngs6ls
  Is Manager: true
  ClusterID: w14h0qps0qydl15l7f356m7rc
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8  
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 192.168.x.x
  Manager Addresses:
   192.168.x.x:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
 Kernel Version: 5.4.0-173-generic
 Operating System: Ubuntu 20.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 23.39GiB
 Name: myServer.com
 ID: CB3V:7M77:KMFB:YZSL:4QYL:RF5V:7RSL:VT5A:OCT2:62ZR:ETM5:7U5P
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: myName
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@ghost
Copy link

ghost commented Mar 11, 2024

I'm also seeing this regression in a different use-case (using docker compose config as input to Kompose).

Caused by a schema change in #11536 and compose-spec/compose-go#509.

I know that the output of docker compose config isn't originally meant for external consumption with external tools, but it would be really nice to have stable output.

The workaround I have now is to pin the official Docker image to an older version (25.0.3), and submit an MR to update Kompose's compose-go version.

@luciangabor
Copy link

The workaround I have now is to pin the official Docker image to an older version (25.0.3), and submit an MR to update Kompose's compose-go version.

You could just overwrite compose:

services:
  cli:
    pull_policy: build
    build:
      dockerfile_inline: |
        FROM docker:cli
        COPY --link --from=docker/compose-bin:v2.24.6 /docker-compose /usr/local/libexec/docker/cli-plugins/

(and the tags can be "plain" envs just like for images)

@ndeloof
Copy link
Contributor

ndeloof commented Mar 11, 2024

compose spec to evolve obviously makes config output to introduce changes, as new attributes are added to the model. config command never has been designed as a "pre-processor" for third party tools. Why don't you just let those parse your original compose file?

@ndeloof
Copy link
Contributor

ndeloof commented Mar 18, 2024

Previous behavior to load env files and populate environment was restored in v2.25

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

No branches or pull requests

3 participants