Skip to content

Exposing bridged ip address to facilitate container to container communcation? #74

Closed

Description

@SwagMuffinMcYoloPants

I saw that there is a method called get_container_host_ip that returns the container's ip depending on if it's in a container or not. I didn't see a way to actually get the bridge ip address of a specific container. The use case that I have is that I have a python integration test that runs localstack container that needs to communicate with multiple containers, one being a database. My localstack container runs a lambda that gets passed an environment variable that says where the database is located. If i use get_container_host_ip to pass the ip to the lambda, it always returns localhost because the python tests are running locally on my machine.

Possible workarounds are running my tests inside of a container so that it never uses localhost. I saw the testcontainers for java has the ability to set the network and so you can use a network alias to communicate between the containers which you can't use when using the bridged network. Another workaround is to just expose a function that returns the bridged IP on the DockerContainer class, but that seems like a hack.

Are there any other alternative solutions?

Activity

  1. tillahoffmann commented on Apr 28, 2020

    @tillahoffmann
    Contributor

    @SwagMuffinMcYoloPants, do the changes @tuvshuud introduced in #85 address your needs?

  2. SwagMuffinMcYoloPants commented on May 1, 2020

    @SwagMuffinMcYoloPants
    Author

    Sorry for the delayed response. Looking at it over quickly, it looks like it would. I double check over the weekend.

  3. SwagMuffinMcYoloPants commented on May 8, 2020

    @SwagMuffinMcYoloPants
    Author

    Hi. I'm so sorry for the delayed response. It looks like this addresses my use case. I appreciate the speedy response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions