Hello friends,
I am nub in terraform and have problem. I want to build and push a docker image in a local docker registry on a remote host. Is there anybody give me a sample for creating that?
my code is like below:
main.tf
###################
resource “docker_container” “registry” {
name = “registry”
image = docker_image.registry.image_id
ports {
internal = 5000
external = 5000
}
volumes {
host_path = “/registry/data”
container_path = “/var/lib/registry”
}
}
resource “docker_image” “registry” {
name = “registry:2”
}
resource “docker_image” “monkit” {
name = “monkit”
build {
path = “…/…”
tag = [“localhost:5000/monkit”]
label = {
author : “saeedya”
}
}
}
providers.tf
###########################
provider “docker” {
registry_auth {
address = “http://localhost:5000”
username = “test”
password = “test”
}
host = “ssh://ubuntu@<remote_server>:22”
ssh_opts = [“-i”, “ssh.key”]
}