Dockerode not opening two ports

283 Views Asked by At

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?

1

There are 1 best solutions below

0
WallMobile On

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