-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[BUG] Error Handling for Self-Referential Dependency in Docker-Compose #11586
Description
Description
I've stumbled upon an admittedly silly mistake on my part that, however, shed light on a significant usability issue with Docker Compose. In a moment of oversight, I configured a Docker service in the docker-compose.yml file to depend on itself. This misstep led to a stack overflow error. The real issue here is not the mistake itself — as embarrassing as it is to admit — but the vague and unclear error message provided when such a scenario occurs.
To reproduce this error, one simply needs to list a service as its own dependency under the depends_on section of the docker-compose.yml file. While I recognize the folly in such a configuration, the expectation would naturally be for Docker Compose to either prevent this configuration due to its inherently problematic nature or, at the very least, offer a clear, understandable error message pinpointing the misconfiguration. Unfortunately, the feedback given is a stack overflow error that lacks direct guidance on how to resolve the issue, which can be perplexing and time-consuming to debug.
I'm fully aware that this mistake might be considered a rookie error, yet it underscores a broader point about the importance of clear, actionable error messages in software development tools. Improving the clarity of error messages in cases like this could significantly enhance the developer experience, making it easier to identify and correct misconfigurations quickly.
I hope this feedback is taken as constructive, with the aim of making Docker Compose even more user-friendly and forgiving, especially for new users who might fall into similar traps. Thank you for considering this enhancement to your error reporting mechanism.
Steps To Reproduce
Here's a simplified example of how the issue can be reproduced in a docker-compose.yml file. This example demonstrates the misconfiguration of a service incorrectly listing itself as its dependency.
version: '3.8'
services:
app:
image: "my-application:latest"
depends_on:
- app # Error: The 'app' service is listed as its own dependency, leading to a stack overflow.Steps to Reproduce the Issue:
- Create a
docker-compose.ymlfile with the content provided above. - Run the command
docker-compose upin the directory containing the file.
Expected Outcome:
Ideally, Docker Compose should identify the circular configuration as invalid and halt execution, providing a clear and specific error message indicating the issue with the circular dependency.
Actual Outcome:
Execution results in a stack overflow, accompanied by an error message that does not clearly specify the nature of the problem, making it difficult for the user to diagnose and correct the configuration error.
Compose Version
Docker Compose version 2.24.7
Docker Environment
Client:
Version: 25.0.3
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: 0.13.0
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.24.7
Path: /usr/lib/docker/cli-plugins/docker-compose
Server:
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 5
Server Version: 25.0.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: true
Native Overlay Diff: false
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 splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7c3aca7a610df76212171d200ca3811ff6096eb8.m
runc version:
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.7.8-arch1-1
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.36GiB
Name: archlinux
ID: MLZX:5KRH:Y4XN:LAAE:4E7H:IKV5:OWMQ:AFK4:ZJ2X:LRNU:D6ST:M4U2
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response