Skip to content

Attach container to an existing network using it's id #4566

Description

@ratcashdev

I'd like to attach a newly pulled container to an existing set of containers (started externally using docker compose) running on network 'docker_default'.
Please advice how could this be done. Thanks.

Or simply allow the compose module to attach to an existing (and running) compose 'project' started from outside and create the socat container inside it so that we are able to do port maps.

Activity

  1. changed the title [-]Attach container to existing network using it's id[/-] [+]Attach container to an existing network using it's id[/+] on Oct 8, 2021
  2. kiview commented on Oct 11, 2021

    @kiview
    Member

    You can instantiate a new Network using the external id:

    Network n = new Network() {
        @Override
        String getId() {
            return "existingId" // use id of external network
        }
    
        @Override
        void close() throws Exception {
    
        }
    
        @Override
        Statement apply(Statement base, Description description) {
            return null
        }
    }
    
    container.withNetwork(n)

    Since this is a question rather than an issue, I converted it to a GH discussion.

  3. locked and limited conversation to collaborators on Oct 11, 2021
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