compose icon indicating copy to clipboard operation
compose copied to clipboard

[BUG] There is no showing error when compose project name is invalid in env file

Open devopsy-ir opened this issue 2 years ago • 1 comments

Description

If you have defined an invalid compose project name in your env file, docker compose will not work correctly and also not show any error!

Steps To Reproduce

  1. Install docker and docker-compose
  2. Write a sample docker-compose.yml file in which a service's port is environment such as: -port: -${PORT}:8080
  3. Write a sample env.sample file with invalid COMPOSE_PROJECT_NAME, such as project.demo, but with no environment PORT defined.
  4. Run: docker-compose --env-file env.sample -f docker-compose.yml ps

Compose Version

2.17.2

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 18
  Running: 16
  Paused: 0
  Stopped: 2
 Images: 16
 Server Version: 23.0.3
 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: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-69-generic
 Operating System: Ubuntu 22.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 47.05GiB
 Name: nilvavm69
 ID: 7d2ed17b-c3a8-4ac2-a55b-4cd707c3547b
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

devopsy-ir avatar Apr 17 '23 10:04 devopsy-ir

IIUC you'd expect compose ps command to warn about invalid project name set in env file? How does this relates to PORT not being defined?

With the current architecture, project name is only validated as resources are created, not when used to inspect actual state, as there's no obvious reason someone would lookup resources with some incorrect name that can't be used to create them. But happy to better understand you use-case and propose a fix accordingly

ndeloof avatar Apr 17 '23 13:04 ndeloof

closing as user didn't provided any feedback for long

ndeloof avatar Oct 24 '24 14:10 ndeloof