Skip to content

Overlay network not found when running single docker on swarm worker #968

@david-baylibre

Description

@david-baylibre
SUMMARY

Overlay network can't be found error when creating a single docker container on a swarm worker part of the cluster.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.docker.docker_container

ANSIBLE VERSION
"2.12.10"
COLLECTION VERSION
# /usr/lib/python3/dist-packages/ansible_collections
Collection       Version
---------------- -------
community.docker 2.6.0  

# ~/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.docker 3.12.1
CONFIGURATION

OS / ENVIRONMENT

Linux Mint 20.3 Una
Linux 5.15.0-117-generic #127~20.04.1-Ubuntu SMP

STEPS TO REPRODUCE

I've set up a docker swarm cluster, host1 and host2 nodes being manager and worker respectively
I create a docker swarm network on the manager and try to create a single docker attached to that network on host2.

- hosts: host1
  become: true
  tasks:
    - name: create docker swarm network
      docker_network:
        name: test_net
        attachable: yes
        driver: overlay

- hosts: host2
  become: true
  tasks:
    - name: alpine
      community.docker.docker_container:
        name: alpine
        image: alpine
        state: started
        networks:
          - name: test_net
EXPECTED RESULTS

This should create the docker attached to test_net network
I use the shell module as a workaround which works just fine:

    - name: alpine
      ansible.builtin.shell:
        cmd: docker run -d --name alpine --network test_net alpine
ACTUAL RESULTS

The network is not found

TASK [alpine] ********************************************************************************************************************************************************************************************************************************
fatal: [host2]: FAILED! => {"changed": false, "msg": "Parameter error: network named test_net could not be found. Does it exist?"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    docker-plainplain Docker (no swarm, no compose, no stack)docker-swarmDocker Swarm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions