代码语言:javascript复制
[root@docker ~]# vim docker-compose.yml
[root@docker ~]# cat docker-compose.yml
registry2:
restart: always
image: registry:2
ports:
- 5002:5002
environment:
REGISTRY_AUTH:htpasswd
REGISTRY_AUTH_HTPASSWD_REALM:Registry Realm
REGISTRY_AUTH_HTPASSWD_PATH:/auth/htpasswd
REGISTRY_HTTP_TLS_CERTIFICATE:/certs/docker.crt
REGISTRY_HTTP_TLS_KEY:/certs/docker.key
volumes:
- /root/data:/var/lib/registry
- /root/certs:/certs
- /root/auth:/auth
[root@docker ~]# ./docker-compose-Linux-x86_64 up -d
ERROR: Validation failed in file './docker-compose.yml', reason(s):
Service 'registry2' configuration key 'environment' contains an invalid type, it should be an object, or an array
[root@docker ~]#
报错2
- 原因是 docker-compose.yml 中environment部分格式不对
- 解决办法:调整格式,加上空格
Tip: environment属性后面的值与
:
之间要有空格REGISTRY_AUTH:htpasswd
是错的REGISTRY_AUTH: htpasswd
是对的