terraform provider + docker registry v2 = 404

I am trying to start some containers using terraform, pulling those from my own registry but just can’t get past the pinging docker server validation, where I get a fugly: * Error pinging Docker server: API error (404): 404 page not found error.

For better explaining this, I started the registry as docker documentation points out; afterwards pushed an image and tried to apply a very basic .tf configuration using terraform:

  • cannot connect to JMX with Spring Boot and Docker
  • Docker: error creating aufs mount to /var/lib/docker/aufs/mnt/15396ee0f38d161382f104e11c94b6ca0efafe10f9952e1dfba4f548009fbe59-init: invalid argument
  • Docker - Jenkins Image
  • Docker stop exiting with 0
  • Docker Compose Setup in Windows 10 for nginx php-fpm fails with Error
  • REST request across networks
  • docker.tf

    # set provider to local registry
    provider "docker" {
        host = "http://docker.localhost.com:5000/v2/ubuntu"
    }
    
    # create container
    resource "docker_container" "test" {
        image = "latest"
        name = "test"
    }
    

    I can pull the manifests and the images using a URL like: http://docker.localhost.com:5000/v2/ubuntu/_manifests/latest without much of a problem but when running terraform things go south and all I get is an error.

    Checking the registry logs I see this when I run terraform:

    `172.*.*.1 - - [04/Apr/2016:18:30:28 +0000] "GET /v2/ubuntu/_ping HTTP/1.1" 404 19 "" "go-dockerclient"`
    

    Tried the same manually using CURL and had a look at the API docs but can’t find anywhere _pingbeing implemented so at this point all I’d ask for is a way to bypass this check. Is there a way to do it?

    I have no authentication set so far, so this (I believe) is no authentication BS… yet.

  • Start service automatic inside Docker container
  • Docker + SSH + Git Clone Isssue
  • java.net.ConnectException when running test with Flyway and embedded Postgresql inside Docker container
  • How to setup private docker registry securely?
  • How to connect my NodeJS with my Angular (in Nginx)
  • How to build a docker image within jenkins
  • One Solution collect form web for “terraform provider + docker registry v2 = 404”

    The docker host in the docker provider points to the Docker daemon and not a docker registry.

    The go-dockerclient that terraform uses internally is hitting this endpoint of the Docker remote API – https://docs.docker.com/engine/reference/api/docker_remote_api_v1.20/#ping-the-docker-server

    To pull from your registry, you will have to do something like below:

    resource "docker_container" "test" {
        image = "docker.localhost.com:5000/org/some-image:latest"
        name = "test"
    }
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.