open icon indicating copy to clipboard operation
open copied to clipboard

Is specifying a Docker network supported?

Open ghost opened this issue 4 years ago • 3 comments

Hello,

We're using Docker Compose to launch Localstack and another container which runs a CloudFormation template against it on launch. To do this, both containers need to be on the same network to resolve the localstack hostname.

I can't find an option in Commandeer to specify the Docker network that Localstack is using. Is this available? If not, is possible to request this as a feature?

Alternatively if anyone else is running a CloudFormation template against Localstack, happy to change our approach.

ghost avatar Aug 19 '21 11:08 ghost

@danw-mpl - Would you specify that in your docker-compose? There is not currently an explicit way to specify it in the Commandeer UI, but I am happy to add that. How exactly would it work?

bwship avatar Aug 19 '21 12:08 bwship

Hello, thanks for replying.

Straight forward enough. Using the standard Docker Compose way of creating named networks. Example:

services:
  localstack:
    {...}
    networks:
      - localstack
    {...}

networks:
  localstack:
    driver: bridge
    name: localstack

In terms of getting the network(s) the container is attached to, there are a couple ways:

Possibly an option although the network 'ID' is present in the array and the user won't know what it is without using the Docker CLI.

$>docker inspect -f '{{range.NetworkSettings.Networks}}{{.Aliases}}{{end}}' localstack_main
[0172d5097474 localstack]

An option to get the first network in the array

$>docker inspect localstack_main | jq -r '.[].NetworkSettings.Networks | keys | first'
localstack

Alternatively you could just run docker inspect localstack_main and work out how to get the network key:

$>docker inspect localstack_main
    {
        "Id": "0172d509747472fa0239dca1bed9a1d88cc2378bfbc15f53089d78e31107f21c",
        {...}
        "NetworkSettings": {
           {...}
            "Networks": {
                "localstack": {
                    {...}
                    "Aliases": [
                        "0172d5097474",
                        "localstack"
                    ],
                    {...}
                }
            }
        }
    }
]

danw-mpl avatar Aug 19 '21 13:08 danw-mpl

Found a workaround for my use case.

To get DNS name resolution working between containers and have Localstack available from the host (for Commandeer), I added two networks to docker-compose.yml.

- default
- localstack

danw-mpl avatar Sep 13 '21 08:09 danw-mpl