community.docker icon indicating copy to clipboard operation
community.docker copied to clipboard

docker_container: Temporary failure in name resolution

Open serpro69 opened this issue 1 year ago • 4 comments

SUMMARY

Container fails to resolve dns names of internal network

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_container

ANSIBLE VERSION
ansible [core 2.13.3]
  config file = ansible.cfg
  configured module search path = ['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = ~/.virtualenvs/oci/lib/python3.8/site-packages/ansible
  ansible collection location = ~/.ansible/galaxy/collections
  executable location = ~/.virtualenvs/oci/bin/ansible
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
Collection       Version
---------------- -------
community.docker 2.7.1
CONFIGURATION
ANSIBLE_NOCOWS(env: ANSIBLE_NOCOWS) = True
COLLECTIONS_PATHS(ansible.cfg) = ['~/.ansible/galaxy/collections']
DEFAULT_JINJA2_EXTENSIONSansible.cfg) = jinja2.ext.do
DEFAULT_LOG_PATH(ansible.cfg) = ansible.log
DEFAULT_ROLES_PATH(ansible.cfg) = ['~/.ansible/galaxy/roles']
INTERPRETER_PYTHON(ansible.cfg) = /usr/bin/python3
OS / ENVIRONMENT
# uname -a
Linux rocinante 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
STEPS TO REPRODUCE
    - docker_container:
        image: liquibase/liquibase:{{ liquibase_version }}
        name: "{{ _liquibase_module }}_liquibase_deploy"
        command:
          - 'update'
          - '--defaultsFile=/liquibase/changelog/liquibase.properties'
          - '--changeLogFile=changelog/{{ liquibase_root_changelog }}'
        volumes:
          - '{{ _liquibase_src }}:/liquibase/changelog:ro'
        working_dir: "{{ playbook_dir }}/../{{ _liquibase_module }}"
        dns_servers:
          - <internal dns server IP>
        #auto_remove: true
        keep_volumes: false
        purge_networks: true
EXPECTED RESULTS

Container (Liquibase) can resolve dns.

Note Running the same from cli works just fine after adding the custom dns server to /etc/default/docker:

# cat /etc/default/docker
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --dns <internal dns server IP>"

Docker command:

docker run -v /path/to/resources/liquibase:/liquibase/changelog liquibase/liquibase:4.16 --defaultsFile=/liquibase/changelog/liquibase.properties --changeLogFile=changelog/changelog-master.xml update
ACTUAL RESULTS

Temporary failure in name resolution

serpro69 avatar Sep 27 '22 08:09 serpro69

Did you compare the docker inspect output of the manually started and the docker_container started container? That might give some hint on what went wrong.

felixfontein avatar Sep 27 '22 10:09 felixfontein

No, I haven't done that . Thanks for the tip @felixfontein , I'll try and see if I can spot any differences and will report back.

serpro69 avatar Oct 01 '22 13:10 serpro69

@serpro69 any news on this?

felixfontein avatar Oct 07 '22 04:10 felixfontein

Hi @felixfontein ,

Yes, I don't really see much differences in the output of docker inspect.

resolv.conf and hosts files are exactly the same for both containers. The dns server IP is present on both resolv.conf files.

Some network config looks a bit different (container created by module on the right):

46,47c46,47
<             "NetworkMode": "bridge",
<             "PortBindings": null,
---
>             "NetworkMode": "default",
>             "PortBindings": {},
49c49
<                 "Name": "",
---
>                 "Name": "no",
58,60c58,60
<             "Dns": null,
<             "DnsOptions": null,
<             "DnsSearch": null,
---
>             "Dns": [],
>             "DnsOptions": [],
>             "DnsSearch": [],

But I guess that the module just reports null instead of empty arrays, so don't think this would affect anything.

Working dir also reports a bit different output, but again, don't think this affects anything or is related to this issue:

<             "WorkingDir": "/home/user/projects/my-liquibase-project/schema-name",
---
>             "WorkingDir": "/liquibase",

Other than this , the rest is pretty much the same.

serpro69 avatar Oct 07 '22 05:10 serpro69

The network mode difference might be important here. The other options are probably irrelevant.

felixfontein avatar Oct 23 '22 15:10 felixfontein

I'm pretty certain I've tried all available network modes that the module supports, and always got the same issue. I'll try again in the next couple of days, just to be sure.

serpro69 avatar Oct 23 '22 15:10 serpro69