commandeer / open

Commandeer is a tool built by developers for developers that solves three things in the cloud. First, we are focused on the deployment of your IAC. Secondly, we enable you to 'Test your Plumbing'. Lastly, Commandeer provides you the ability to easily view your data.
https://getcommandeer.com
MIT License
141 stars 26 forks source link

Is specifying a Docker network supported? #198

Open danw-mpl opened 3 years ago

danw-mpl commented 3 years ago

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.

bwship commented 3 years ago

@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?

danw-mpl commented 3 years ago

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 commented 3 years ago

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