Ansible docker_login module error : Error while fetching server API version

402 Views Asked by At

I am trying to login to private docker container registry using Ansible module (docker_login) on Mac. It works fine on Ubuntu latest, however Mac fails with below error. I have tried installing pip module for docker, docker-py and requests. none of these helps.

"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))"

Code Block:

- name: Login to Docker Registry
  hosts: localhost
  tasks:  

    - name: Install docker
      pip:
        name: docker
        
    - name: Install docker
      pip:
        name: requests

    - name: login
      docker_login:
        registry: "registryhidden"
        username: "user"
        password: "password"

    - name: Pull image
      docker_image:
        name: registryhidden/hellow-world:2.2.0
        source: pull

Login succeed and pull the image

Docker Info

Docker info
Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.10.0)
  compose: Docker Compose (Docker Inc., v2.15.1)
  dev: Docker Dev Environments (Docker Inc., v0.0.5)
  extension: Manages Docker extensions (Docker Inc., v0.2.17)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.23.0)

Server:
 Containers: 38
  Running: 34
  Paused: 0
  Stopped: 4
 Images: 33
 Server Version: 20.10.22
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 7.668GiB
 Name: docker-desktop
 ID: EGCA:3ZEX:YMYL:IUTN:FGUA:FOIQ:JIVQ:4B27:TMYK:3YDO:DSH2:WCN5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

➜  Downloads 

0

There are 0 best solutions below