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

Is there a way to output a warning about key duplication in docker-compose.yaml? #7465

Closed
oshiro3 opened this issue May 17, 2020 · 2 comments

Comments

@oshiro3
Copy link

oshiro3 commented May 17, 2020

Description of the issue

Currently, in the description of the docker-compose.yml file, if I register the same key in the same service definition, the value defined later will be applied. This issue cannot be detected by docker-compose's validation feature. Upon investigation, it is the specification of the safe_load method of the pyyaml ​​standard library, and currently pyyaml ​​does not seem to take any measures.
 yaml/pyyaml#165

I need to manually check that the same key is not defined in the docker-compose.yml file in our project.
I would like to solve this problem with docker-compose's validation feature if possible.

The following issues have been closed, is this a resolved issue?
I would like to know if there are already cases of countermeasures.
I would also like to know if it is an issue that should be addressed in our project.
#5267

Output of docker-compose version

docker-compose version 1.25.5, build 8a1c60f6

Output of docker version

Client:
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        369ce74a3c
 Built:             Fri Feb 28 23:45:43 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.6
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       369ce74a3c
  Built:            Wed Feb 19 01:06:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.3-0ubuntu1~18.04.2
  GitCommit:        
 runc:
  Version:          spec: 1.0.1-dev
  GitCommit:        
 docker-init:
  Version:          0.18.0
  GitCommit:        

Steps to reproduce the issue

  1. write compose.yaml
version: '3'
services:
     nginx:
        image: nginx
        environment:
            - 'testenv1=1'
        environment:
            - 'testenv2=2'
  1. output config
$docker-compose config

services:
     nginx:
        environment:
            testenv1: 1
        image: nginx

Expected result

$docker-compose config
services:
     nginx:
        environment:
            testenv1: 1
            testenv2: 2
        image: nginx

or

$docker-compose config
WARNING: environment is duplicated. ....

Additional information

OS version / distribution, docker-compose install method, etc.

@stale
Copy link

stale bot commented Nov 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2020
@stale
Copy link

stale bot commented Nov 21, 2020

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Nov 21, 2020
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

1 participant