0

当我尝试在创建选项中创建第二个端口时,它会正确创建第一个端口,但不会创建第二个端口。

"createOptions": {
  "Env": [
    "DATA_DIR=/tmp/localstack/data",
    "DOCKER_HOST=unix:///var/run/docker.sock",
    "SERVICES=apigateway"
  ],
  "Image": "localstack/localstack:0.12.10",
  "name": "commandeer-localstack-default-local",
  "ExposedPorts": {
    "443/tcp:": {}
  },
  "HostConfig": {
    "PortBindings": {
      "4566/tcp": [
        {
          "HostPort": "4566"
        }
      ],
      "443/tcp": [
        {
          "HostPort": "443"
        }
      ]
    },
    "AutoRemove": true,
    "Binds": [
    "/var/run/docker.sock:/var/run/docker.sock"
  ]
  }
}

这应该暴露 4566 和 443,但是当我检查新创建的容器时,它有这个信息。

      "Bridge": "",
      "SandboxID": "f55fe8aad382e3fb418c419bdee6ad52c2540c160b93d0f7164a5cd8088ea00a",
      "HairpinMode": false,
      "LinkLocalIPv6Address": "",
      "LinkLocalIPv6PrefixLen": 0,
      "Ports": {
        "443/0": null,
        "4566/tcp": [
         {
           "HostIp": "0.0.0.0",
           "HostPort": "4566"
         }
        ],
        "4571/tcp": null,
        "8080/tcp": null
     },

您可以看到 4566 设置正确,但 443/0 : null 用于 443 端口。我已经尝试过没有 ExposedPorts 部分,更改了 HostOptions 的顺序等。但它仍然无法正常工作。有任何想法吗?

4

1 回答 1

0

所以,我终于让这个工作了。我将 HostIp 设置为空字符串。我仍然需要为 443 使用 ExposedPorts。但这确实对我有用。

"createOptions": {
  "Env": [
    "DATA_DIR=/tmp/localstack/data",
    "DOCKER_HOST=unix:///var/run/docker.sock",
    "SERVICES=apigateway"
  ],
  "Image": "localstack/localstack:0.12.10",
  "name": "commandeer-localstack-default-local",
  "ExposedPorts": {
    "443/tcp:": {}
  },
  "HostConfig": {
    "PortBindings": {
      "4566/tcp": [
        {
          "HostPort": "4566",
          "HostIp": ""
        }
      ],
      "443/tcp": [
        {
          "HostPort": "443"
          "HostIp": ""
        }
      ]
    },
    "AutoRemove": true,
    "Binds": [
    "/var/run/docker.sock:/var/run/docker.sock"
  ]
  }
}
``
于 2021-07-13T13:01:24.993 回答