0

When I attempt to have a second port in the create options, it correctly creates the first, but not the second port.

"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"
  ]
  }
}

This should expose 4566 and 443, but when I inspect the newly created container, it has this info.

      "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
     },

You can see that 4566 is setup correctly, but 443/0 : null for the 443 port. I have tried this without the ExposedPorts section, changed the order of the HostOptions, etc. But it still never works. Any ideas?

WallMobile
  • 1,939
  • 1
  • 20
  • 35
  • Can you try a different port other than 443 and check . 443 might be used by your host – abhishek phukan Jul 09 '21 at 17:16
  • @abhishekphukan - yea I tried to just do something like 4570 and had the same result that it would just have 4570/0: null – WallMobile Jul 09 '21 at 17:24
  • Also, if I stand this same thing up using docker compose, specifying the 443 port, it does work correctly. Just seems to not work with dockerode. – WallMobile Jul 09 '21 at 17:25
  • I have the same issue but [this article](https://stackoverflow.com/questions/20845056/how-can-i-expose-more-than-1-port-with-docker) fit for me – itshosyn Jul 09 '21 at 17:31

1 Answers1

0

So, I got this to finally work. I set the HostIp to an empty string. I still needed to use the ExposedPorts for 443. But this did work for me.

"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"
  ]
  }
}
``
WallMobile
  • 1,939
  • 1
  • 20
  • 35