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:

  • Node https.request to Docker API closes before full result is returned
  • Docker-compose specify config file
  • Cannot run my docker image
  • GitLab CI Runner, how to use volumes or mounts in service containers
  • Behat Mink file upload not finding file on submit
  • How to do a none interactive pecl install stomp
  • 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.

  • Failed to resolve 'kafka:9092': Name or service not known - docker / php-rdkafka
  • Unable to connect to dockerized postgres on localhost, but remote connection is working
  • How to play a docker run --rm with docker-java?
  • curl_slist_free_all() causes segfault on GKE w/ Debian 8.7
  • Range of IP address to be allowed from internal network for Bluemix Containers
  • docker-compose: difference between network and link
  • 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.