Question

Deploy Docker Image from DockerHub as App via Terrafiom

Hey guys … I’m trying to deploy an App via Terraform. I want to use one of my public Images from DockerHub.

The DigitalOcean Provider works (confirmed that with an other PoC).

Now I want to deploy a Docker image as an App. I found the digitalocean_app resource (https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/app). The docs state, that I have to set “registry_type” to one of DOCR (DigitalOcean container registry) or DOCKER_HUB.

But I don’t really know how. This is my config.

resource "digitalocean_app" "docs-page-docker-app" {
  spec {
    name   = "docs-page-docker-app"
    region = "fra1"

    # domain

    service {
      name      = "docs-page-docker-app-image"
      http_port = 3000

      image {
        registry_type = "DOCKER_HUB"
        repository    = "sommerfeldio/docs-website"
        tag           = "stable"
      }
    }
  }
}

When I put DOCKER_HUB in quotation marks ("), I always get the error “Image does not exist or is private”. When I remove the quotation marks, my config is no longer valid.

From the docs I don’t really get how I have to specify that I want to use DockerHub as container registry. Anyone got an Idea on how I could tackle this issue?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Your Terraform configuration looks correct. But I believe that the App Platform currently does not support private Docker Hub images. I believe that this feature might already be on the DigitalOean roadmap but there is no publicly announced ETA yet.

If you need to use a private container registry, you could do that with the DigitalOcean Container Registry which is private:

https://docs.digitalocean.com/products/container-registry/

Best,

Bobby