ERROR: yaml.scanner.ScannerError: mapping values are not allowed here The Compose file ‘./docker-com
Posted 抛物线.
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERROR: yaml.scanner.ScannerError: mapping values are not allowed here The Compose file ‘./docker-com相关的知识,希望对你有一定的参考价值。
[root@devops composeapp]# vi docker-compose.yml
web:
image:pwx/composeapp
command:python app.py
ports:
-"5000:5000"
volumes:
-.:/composeapp
links:
-redis
redis:
image:redis
执行后报错
[root@devops composeapp]# docker-compose up
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in "./docker-compose.yml", line 4, column 7
执行docker中的yml命令报错时 一定要看清楚yml的严格的格式书写要求
要求每个冒号 和每个 - 符号后面必须有一个空格
root@devops composeapp]# vi docker-compose.yml
web:
image: pwx/composeapp
command: python app.py
ports:
- "5000:5000"
volumes:
- .:/composeapp
links:
- redis
redis:
image: redis
如果 - 符号后面没有空格 也会报错
[root@devops composeapp]# docker-compose up
ERROR: The Compose file './docker-compose.yml' is invalid because:
web.volumes contains an invalid type, it should be an array
web.links contains an invalid type, it should be an array
web.ports contains an invalid type, it should be an array
所以- 号后面也要注意空格
这样就可以啦
[root@devops composeapp]# docker-compose up
Pulling redis (redis:)...
latest: Pulling from library/redis
fc7181108d40: Already exists
3e0ac67cad82: Pull complete
6ee495cb7235: Pull complete
9f7206d08b9d: Pull complete
a8354ef8cccb: Pull complete
53afb10d81c2: Pull complete
Digest: sha256:ca2d9251c2818df48c6598e01a5bdeab46040dc7ab236abe075d7c7343465177
Status: Downloaded newer image for redis:latest
Creating composeapp_redis_1 ... done
Creating composeapp_web_1 ... done
Attaching to composeapp_redis_1, composeapp_web_1
redis_1 | 1:C 23 Jun 2019 12:37:59.151 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 23 Jun 2019 12:37:59.151 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 23 Jun 2019 12:37:59.151 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | 1:M 23 Jun 2019 12:37:59.154 * Running mode=standalone, port=6379.
redis_1 | 1:M 23 Jun 2019 12:37:59.154 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 23 Jun 2019 12:37:59.154 # Server initialized
redis_1 | 1:M 23 Jun 2019 12:37:59.154 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1 | 1:M 23 Jun 2019 12:37:59.154 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1 | 1:M 23 Jun 2019 12:37:59.154 * Ready to accept connections
web_1 | * Serving Flask app "app" (lazy loading)
web_1 | * Environment: production
web_1 | WARNING: This is a development server. Do not use it in a production deployment.
web_1 | Use a production WSGI server instead.
web_1 | * Debug mode: on
web_1 | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
web_1 | * Restarting with stat
web_1 | * Debugger is active!
web_1 | * Debugger PIN: 314-971-920
以上是关于ERROR: yaml.scanner.ScannerError: mapping values are not allowed here The Compose file ‘./docker-com的主要内容,如果未能解决你的问题,请参考以下文章
新浪微博Error_code: 400; Error: 40022:Error: source paramter(appkey) is missing的解决方法
Error 500--Internal Server Error如何解决
在 MySQL 中出现 ERROR 1701、ERROR 1452 和 ERROR 1305 错误 - 需要一些专业知识