dokploy_network (Resource)
A Docker network that Dokploy manages. Attach services to it as an extra network beside the default dokploy-network. See network_ids on dokploy_application and the database resources, and service_networks on dokploy_compose.
~> Networks are immutable. Dokploy has no update endpoint, so a change to any attribute replaces the network. Attached services continue to work until their next deploy. Attach them to the replacement id, which a dokploy_network.<name>.id reference does automatically, and deploy them again.
~> A delete of an attached network does not fail and does not detach it. network.remove succeeds while an application still references the network in its network_ids. The reference stays until the next update or deploy of that application.
-> A network from outside Dokploy, for example from docker network create, has no Dokploy id. Import it once in the Dokploy UI (Networks > Import), then read it with the dokploy_network data source or terraform import.
Example Usage
resource "dokploy_network" "backend" {
name = "backend-net"
# Networks are immutable: a change to any attribute replaces the network.
# attachable = true
# mtu = 1400
# ipam = {
# config = [{ subnet = "172.28.0.0/16" }]
# }
}
# Attach a service to it. The attachment applies on the next deploy of the service:
# resource "dokploy_application" "api" {
# # ...
# network_ids = [dokploy_network.backend.id]
# }Schema
Required
name(String) Network name. A change replaces the network.
Optional
attachable(Boolean) Allow manual container attachment, for overlay networks.driver(String) Network driver:bridgeoroverlay. Defaults tobridge.enable_ipv4(Boolean) Enable IPv4 on the network.enable_ipv6(Boolean) Enable IPv6 on the network.internal(Boolean) Restrict external access to the network.ipam(Attributes) Custom IP address management. If unset, the Docker defaults apply. (see nested schema for ipam)mtu(Number) MTU for the network, 68 to 65535. If unset, the Docker default applies.server_id(String) Id of the remote server that hosts the network. If unset, the Dokploy host applies.
Read-Only
created_at(String) Creation timestamp from the server.id(String) Network id.
Nested Schema for ipam
Optional:
config(Attributes List) Address pools. (see nested schema for ipam.config)driver(String) IPAM driver, for exampledefault.
Nested Schema for ipam.config
Optional:
gateway(String) Gateway address for the pool.ip_range(String) Sub-range for allocation, in CIDR form.subnet(String) Pool subnet in CIDR form, for example172.28.0.0/16.
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:
# Networks created in the Dokploy UI (including UI-imported Docker networks)
# can be adopted by id:
import {
to = dokploy_network.backend
id = "V1StGXR8_Z5jdHi6B-myT"
}The terraform import command can be used, for example:
terraform import dokploy_network.backend V1StGXR8_Z5jdHi6B-myT