Containers doesn't attach to Swarm network
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Hi guys,
I'm trying to create a swarm service that is running across two nodes:
container_spec = docker.types.ContainerSpec(
image=service.get("image"),
env=service["environment"],
mounts=service["volumes"],
command=service["command"],
labels={"task": str(task_id)},
)
task_tmpl = docker.types.TaskTemplate(
container_spec=container_spec,
networks=[network.id],
placement=docker.types.Placement(constraints=service["deploy"]["placement"]["constraints"])
)
docker_service = client.create_service(
task_template=task_tmpl,
name=f"{task_id}_master",
mode=service["deploy"]["mode"],
networks=[network.id],
labels={"task": str(task_id)},
)
network = client.networks.create(
name=f"{task_id}_default", scope="swarm", driver="overlay", labels={"task": str(task_id)}, attachable=True
)
The problem is that the containers on the the second node doesn't connect to the network.
It doesn't matter if I inspect with client.networks.list(filters={"label": f"task={task_id}"}, greedy=True)[0] or use the docker cli
Any ideas?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two-node Swarm setup from the issue, starting with client.networks.create, create_service, and networks.list and comparing the network state on both nodes. Determine why the service containers on the second node are not attached, then verify that the reported network inspection and CLI output show the expected attachment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100