docker / docker/docker-py

docker containers connected to a network when run won't show up in network_object.containers field

Open
#2,235 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/question level/dockerclient
Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

when running a container with

client.containers.run(.....,
                                 network=net1,
                                 ......)

the container ends up connected to the network, but when calling net1.containers on the network object, it returns an empty list ([])
When re-getting the network object with
client.networks.get(net1_name),
the container shows up.

to reproduce this bug:

  1. create a network object with client.networks.create
  2. run a container with client.containers.run, with parameter network = (the name of the net you created)
  3. check network_object.containers field and see it's empty
  4. do client.networks.get(net1_name) to re-get the object and see that now the container is present in
    checked this issue with two different hosts with different docker versions, both reproduced the bug.

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

Reproduce the sequence using client.networks.create, client.containers.run with the network name, and client.networks.get, then inspect how network_object.containers is populated and refreshed. No file or test is named in the issue; done means the original network object reports the connected container without requiring a second get.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
networking
Issue type
Bug
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.