ask
ask

Reputation: 79

How do i pull from insecure docker registry with ansible?

TLDR; I want ansible to pull a docker image through http not https.

I have two VMs running in the same network. On one is a local docker registry. The other should pull images from the former via an ansible script. However, I get an error that the registry expects https and is http.

This seemed to solve the problem before. Ansible task for run Docker container from private registry

Unfortunateley, ansible docker: is outdated, and I need to use docker_container, and the latter does not have a insecure_registry option.

This is how it looks like now

  - name: Run kollega 
    docker_container:
      name: image_name
      image: "ip-to-registry/image:latest"
      ports:
        - "4000:4000"
      restart_policy: unless-stopped
      recreate: yes
      pull: yes
      env:

Is there some magic command I can add here to accept http registries, or must I just generate som self-signend certs?

Upvotes: 6

Views: 1524

Answers (1)

Sachith Muhandiram
Sachith Muhandiram

Reputation: 2972

In the target node(s) you are reaching with ansible, add this to /etc/docker/daemon.json

{
  "insecure-registries" : ["your-registry:5000"]
}

systemctl restart docker

Reference

Upvotes: 4

Related Questions