ERROR: yaml.scanner.ScannerError: mapping values are not allowed here The Compose file ‘./docker-com

14 篇文章 2 订阅
10 篇文章 0 订阅
[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

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

抛物线.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值