testcontainers / testcontainers/testcontainers-python

Feature: A way to construct a `Network` object for an existing docker network

Open
#816 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🚀 enhancement
Dominant language
Python
Stars
2.3k
Forks
386
Avg merge
4h 40m
Merged PRs (30d)
1

Description

What are you trying to do?

Attach a DockerContainer to an existing network. In my specific case, the network was created as part of a composable setup, and I'd like to attach a new container to that network.

Why should it be done this way?

I suppose my suggestion would be a way to construct a Network object by simply passing the name in as an argument. Best I can tell that name property is all that is really needed when the DockerContainer is started.

A perhaps easier way might be to create a new class

class ExistingNetwork:
    def __init__(self, network_name: str):
        self.name = network_name

While this I think could be passed into DockerContainer.with_network & it seems to work, it might be better to have this inherit Network and explicitly override the other methods in the Network class to ensure they are not called.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core/testcontainers/core/network.py around the Network name property and inspect DockerContainer.with_network. Determine how an existing network name can be represented without creating or managing the network, then verify that a DockerContainer can attach to it when started.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
devops, infrastructure
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.