在docker-compose.yml中的services节点添加:

nexus:
    image: sonatype/nexus3
    ports:
      - "8082:8081"
       # 开放docker私服的端口,这个端口可以随意配置
      - "8084:8080"
    volumes:
      - "/home/docker/nexus:/nexus-data"
    deploy:
      placement:
        constraints: [node.role == manager]
    networks:
      - webnet