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

dokploy_mount (Resource)

A volume, bind, or file mount on a Dokploy service.

~> Database services create their own data mount. A dokploy_postgres (or mysql/mariadb/mongo/redis/libsql) owns a volume mount for its data directory from the moment of its creation, without a request for it. That mount belongs to the server, not to Terraform. Do not import it, and do not declare it here.

Example Usage

terraform
# A named Docker volume for the uploads directory of an application.
resource "dokploy_mount" "uploads" {
  service_id   = dokploy_application.web.id
  service_type = "application"

  type        = "volume"
  volume_name = "web-uploads"
  mount_path  = "/app/uploads"
}

# A bind mount from a path on the Dokploy host.
resource "dokploy_mount" "certs" {
  service_id   = dokploy_application.web.id
  service_type = "application"

  type       = "bind"
  host_path  = "/etc/ssl/private/app"
  mount_path = "/certs"
}

# A file that Dokploy writes into the container at deploy time.
resource "dokploy_mount" "config" {
  service_id   = dokploy_application.web.id
  service_type = "application"

  type       = "file"
  mount_path = "/app/config"
  file_path  = "settings.json"
  content    = jsonencode({ log_level = "info" })
}

Schema

Required

  • mount_path (String) Mount path inside the container.
  • service_id (String) Id of the service that this mount attaches to. A change forces a replacement: the Dokploy update endpoint sets the new parent without a clear of the old one, and the mount then belongs to two services at once.
  • service_type (String) Kind of service that service_id refers to: one of application, postgres, mysql, mariadb, mongo, redis, compose, libsql. A change forces a replacement, for the same reason as service_id.
  • type (String) Mount kind: bind (a host path), volume (a named Docker volume), or file (inline content that Dokploy writes into the container).

Optional

  • content (String) Contents of the file. Required when type is file, and invalid otherwise.
  • file_path (String) File name to create inside mount_path. Required when type is file, and invalid otherwise.
  • host_path (String) Absolute path on the host. Required when type is bind, and invalid otherwise.
  • volume_name (String) Name of the Docker volume. Required when type is volume, and invalid otherwise.

Read-Only

  • id (String) Mount 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
# Mounts import by their own id; the parent service is recovered from the record.
import {
  to = dokploy_mount.uploads
  id = "m1a2b3c4d5e6f7g8h9i0j"
}

The terraform import command can be used, for example:

shell
terraform import dokploy_mount.uploads m1a2b3c4d5e6f7g8h9i0j