使用compose:publish将容器部署到docker swarm:不允许发布其他属性发布

时间:2017-09-03 18:56:33

标签: docker docker-compose docker-swarm

以下不起作用,你知道为什么吗?

这是错误:不允许发布附加属性发布

version: "3"
services:
  app:
    image: golang:1.9
    working_dir: /app/src
    command: go run main.go
    volumes:
      - ./app:/app/src/
    publish:
      - "8080:8080"

docker version

Client:
 Version:      17.06.1-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:53:38 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.07.0-ce
 API version:  1.31 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   8784753
 Built:        Tue Aug 29 17:46:50 2017
 OS/Arch:      linux/amd64
 Experimental: false

1 个答案:

答案 0 :(得分:2)

您应该使用端口而不是发布

version: "3"
services:
  app:
    image: golang:1.9
    working_dir: /app/src
    command: go run main.go
    volumes:
      - ./app:/app/src/
    ports:
      - "8080:8080"