geerlingguy / ansible-for-kubernetes

Ansible and Kubernetes examples from Ansible for Kubernetes Book
https://www.ansibleforkubernetes.com
MIT License
686 stars 313 forks source link

Chapter 3 - Ansible manages containers Page 48 #100

Open johnathanPaterson opened 3 years ago

johnathanPaterson commented 3 years ago

ansible --version ansible [core 2.11.2] config file = /etc/ansible/ansible.cfg configured module search path = ['/home/jp/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/jp/.local/lib/python3.8/site-packages/ansible ansible collection location = /home/jp/.ansible/collections:/usr/share/ansible/collections executable location = /home/jp/.local/bin/ansible python version = 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0] jinja version = 2.10.1 libyaml = True

docker version Client: Docker Engine - Community Version: 20.10.7 API version: 1.41 Go version: go1.13.15 Git commit: f0df350 Built: Wed Jun 2 11:57:03 2021 OS/Arch: linux/arm64 Context: default Experimental: true

Server: Docker Engine - Community Engine: Version: 20.10.7 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: b0f5bc3 Built: Wed Jun 2 11:55:14 2021 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.4.6 GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d runc: Version: 1.0.0-rc95 GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7 docker-init: Version: 0.19.0 GitCommit: de40ad0

On executing ansible-playbook -i inventory registry.yml

[DEPRECATION WARNING]: The container_default_behavior option will change its default value from "compatibility" to "no_defaults" in community.docker 2.0.0. To remove this warning, please specify an explicit value for it now. This feature will be removed from community.docker in version 2.0.0. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Invalid port: \"50001~\""}

If I read correctly

- name: Run the Docker Registry container locally.
  docker_container:
    name: registry
    image: '{{ registry_image }}'
    state: started
    published_ports:
      - 5000:5000
    container_default_behavior: compatibility <-- This should fix the warning

However, the new output for (Page 49) docker push localhost:5000/test-image is:

Using default tag: latest The push refers to repository [localhost:5000/test-image] Get http://localhost:5000/v2/: read tcp 127.0.0.1:36968->127.0.0.1:5000: read: connection reset by peer

not

The push refers to repository [localhost:5000/test-image] 77cae8ab23bf: Pushed latest: digest: sha256:e4355b66995c96b4b4681... size: 528

I have not found help online.

johnathanPaterson commented 3 years ago

Seems I had a typo of the Port number, 50001 instead of 5000, that accounts for "fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Invalid port: "50001~""}". However, placing "container_default_behavior: compatibility" under "docker_container:" in both "registry.yml" and "main.yml" removes the DEPRECATION WARNING.