skip to content
wihan.dev
view as markdown
browse the dokploy docs

dokploy_port (Resource)

A published port on a Dokploy application. It maps a host port to a container port.

Example Usage

terraform
resource "dokploy_port" "metrics" {
  application_id = dokploy_application.web.id
  published_port = 9100
  target_port    = 9100
  protocol       = "tcp"
  publish_mode   = "host"
}

Schema

Required

  • application_id (String) Id of the application that owns this record. A change forces a replacement: the Dokploy update endpoint for this record type has no parent field, so a record cannot move between applications.
  • published_port (Number) Port published on the host.
  • target_port (Number) Port that the container listens on.

Optional

  • protocol (String) Transport protocol: tcp or udp.
  • publish_mode (String) Swarm publish mode: host or ingress.

Read-Only

  • id (String) Record id.

Import

Import is supported using the following syntax:

In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:

terraform
import {
  to = dokploy_port.metrics
  id = "p1a2b3c4d5e6f7g8h9i0j"
}

The terraform import command can be used, for example:

shell
terraform import dokploy_port.metrics p1a2b3c4d5e6f7g8h9i0j