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.

Bobby Iliev
Site Moderator
Site Moderator badge
October 9, 2022

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.