提供端口作为字符串时的Composer文件错误

时间:2019-06-17 10:12:09

标签: docker docker-compose dockerfile

当我尝试运行以下docker-compose文件时,出现以下错误:

  

wordpress.ports包含无效的类型,它应该是一个数组   phpmyadmin.ports包含无效类型,应为数组   phpmyadmin.environment包含无效的类型,应为   对象或数组

wordpress:
image: wordpress
links: "wordpress_db:mysql"
ports: "8080:80"

wordpress_db:
image: mariadb
environment: "MY_SQL_ROOT_PASSWORD: niti"

phpmyadmin:
image: corbinu/docker-phpmyadmin
links: "wordpress_db:mysql"
ports: "8181:80"
environment: "MY_SQL_USERNAME: root"
environment: "MY_SQL_ROOT_PASSWORD: niti"

2 个答案:

答案 0 :(得分:1)

wordpress:
  image: wordpress
  links: "wordpress_db:mysql"
  ports: 
    - "8080:80"

wordpress_db:
  image: mariadb
  environment: "MY_SQL_ROOT_PASSWORD: niti"

phpmyadmin:
  image: corbinu/docker-phpmyadmin
  links: "wordpress_db:mysql"
  ports: 
    - "8181:80"
  environment: "MY_SQL_USERNAME: root"
  environment: "MY_SQL_ROOT_PASSWORD: niti"`

它需要一个数组列表,因此您应该提供一个列表:它通过在端口字符串之前添加-来检测列表

答案 1 :(得分:1)

您的撰写文件存在格式问题,它希望将列表作为输入而不是映射。我已暂时修复-

version: "3"

services:
  wordpress:
    image: wordpress
    links:
      - wordpress_db
    ports:
      - "8080:80"

  wordpress_db:
    image: mariadb
    environment:
      - MY_SQL_ROOT_PASSWORD=niti

  phpmyadmin:
    image: corbinu/docker-phpmyadmin
    links:
      - wordpress_db:mysql
    ports:
      - 8181:80
    environment:
      - MY_SQL_USERNAME=root
      - MY_SQL_ROOT_PASSWORD=niti