2021-03-18 03:30:54 -04:00
package provider
2015-02-17 11:28:33 -05:00
import (
2021-03-18 03:30:54 -04:00
"context"
2019-03-05 09:55:17 -05:00
"log"
2021-03-18 03:30:54 -04:00
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2015-02-17 11:28:33 -05:00
)
func resourceDockerContainer ( ) * schema . Resource {
return & schema . Resource {
2021-05-21 08:30:56 -04:00
Description : "Manages the lifecycle of a Docker container." ,
2021-03-18 03:30:54 -04:00
CreateContext : resourceDockerContainerCreate ,
ReadContext : resourceDockerContainerRead ,
UpdateContext : resourceDockerContainerUpdate ,
DeleteContext : resourceDockerContainerDelete ,
2019-03-05 09:55:17 -05:00
MigrateState : resourceDockerContainerMigrateState ,
2019-11-14 17:10:48 -05:00
SchemaVersion : 2 ,
2019-11-23 08:42:05 -05:00
Importer : & schema . ResourceImporter {
2021-03-18 03:30:54 -04:00
StateContext : schema . ImportStatePassthroughContext ,
2019-11-23 08:42:05 -05:00
} ,
2019-11-14 17:10:48 -05:00
StateUpgraders : [ ] schema . StateUpgrader {
{
Version : 1 ,
Type : resourceDockerContainerV1 ( ) . CoreConfigSchema ( ) . ImpliedType ( ) ,
2021-03-18 03:30:54 -04:00
Upgrade : func ( ctx context . Context , rawState map [ string ] interface { } , meta interface { } ) ( map [ string ] interface { } , error ) {
2020-12-02 06:06:39 -05:00
// TODO do the ohter V0-to-V1 migration, unless we're okay
// with breaking for users who straggled on their docker
// provider version
2019-11-14 17:10:48 -05:00
2019-11-14 17:44:58 -05:00
return migrateContainerLabels ( rawState ) , nil
2019-11-14 17:10:48 -05:00
} ,
} ,
} ,
2015-02-17 11:28:33 -05:00
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"name" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The name of the container." ,
Required : true ,
ForceNew : true ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"rm" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
2021-12-03 05:38:55 -05:00
Description : "If `true`, then the container will be automatically removed when it exits. Defaults to `false`." ,
2021-05-21 08:30:56 -04:00
Default : false ,
Optional : true ,
2018-10-25 02:01:38 -04:00
} ,
2019-10-25 06:14:09 -04:00
"read_only" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, the container will be started as readonly. Defaults to `false`." ,
Default : false ,
Optional : true ,
ForceNew : true ,
2019-10-25 06:14:09 -04:00
} ,
2019-03-01 16:02:17 -05:00
"start" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, then the Docker container will be started after creation. If `false`, then the container is only created. Defaults to `true`." ,
Default : true ,
Optional : true ,
2018-10-08 14:14:01 -04:00
} ,
2019-03-01 16:02:17 -05:00
"attach" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true` attach to the container after its creation and waits the end of its execution. Defaults to `false`." ,
Default : false ,
Optional : true ,
2018-10-28 13:41:10 -04:00
} ,
2019-03-01 16:02:17 -05:00
"logs" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "Save the container logs (`attach` must be enabled). Defaults to `false`." ,
Default : false ,
Optional : true ,
2018-10-28 13:41:10 -04:00
} ,
2015-02-17 11:28:33 -05:00
// Indicates whether the container must be running.
//
// An assumption is made that configured containers
// should be running; if not, they should not be in
// the configuration. Therefore a stopped container
// should be started. Set to false to have the
// provider leave the container alone.
//
// Actively-debugged containers are likely to be
// stopped and started manually, and Docker has
// some provisions for restarting containers that
// stop. The utility here comes from the fact that
// this will delete and re-create the container
// following the principle that the containers
// should be pristine when started.
2019-03-01 16:02:17 -05:00
"must_run" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, then the Docker container will be kept running. If `false`, then as long as the container exists, Terraform assumes it is successful. Defaults to `true`." ,
Default : true ,
Optional : true ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"exit_code" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The exit code of the container if its execution is done (`must_run` must be disabled)." ,
Computed : true ,
2018-10-25 02:01:38 -04:00
} ,
2019-03-01 16:02:17 -05:00
"container_logs" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The logs of the container if its execution is done (`attach` must be disabled)." ,
Computed : true ,
2018-10-28 13:41:10 -04:00
} ,
2015-02-17 11:28:33 -05:00
// ForceNew is not true for image because we need to
// sane this against Docker image IDs, as each image
// can have multiple names/tags attached do it.
2019-03-01 16:02:17 -05:00
"image" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The ID of the image to back this container. The easiest way to get this value is to use the `docker_image` resource as is shown in the example." ,
Required : true ,
ForceNew : true ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"hostname" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Hostname of the container." ,
Optional : true ,
ForceNew : true ,
Computed : true ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"domainname" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Domain name of the container." ,
Optional : true ,
ForceNew : true ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"command" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeList ,
Description : "The command to use to start the container. For example, to run `/usr/bin/myprogram -f baz.conf` set the command to be `[\"/usr/bin/myprogram\",\"-\",\"baz.con\"]`." ,
Optional : true ,
ForceNew : true ,
Computed : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"entrypoint" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeList ,
Description : "The command to use as the Entrypoint for the container. The Entrypoint allows you to configure a container to run as an executable. For example, to run `/usr/bin/myprogram` when starting a container, set the entrypoint to be `\"/usr/bin/myprogra\"]`." ,
Optional : true ,
ForceNew : true ,
Computed : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
2015-10-26 17:24:48 -04:00
} ,
2019-03-01 16:02:17 -05:00
"user" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "User used for run the first process. Format is `user` or `user:group` which user and group can be passed literraly or by name." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
2020-11-29 08:39:09 -05:00
DiffSuppressFunc : func ( k , oldV , newV string , d * schema . ResourceData ) bool {
// treat "" as a no-op, which is Docker's default value
if newV == "" {
newV = oldV
}
return oldV == newV
} ,
2016-04-04 22:43:59 -04:00
} ,
2019-03-01 16:02:17 -05:00
"dns" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "DNS servers to use." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"dns_opts" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "DNS options used by the DNS provider(s), see `resolv.conf` documentation for valid list of options." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2016-06-29 08:38:46 -04:00
} ,
2019-03-01 16:02:17 -05:00
"dns_search" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "DNS search domains that are used when bare unqualified hostnames are used inside of the container." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2016-06-29 08:38:46 -04:00
} ,
2019-03-01 16:02:17 -05:00
"publish_all_ports" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "Publish all ports of the container." ,
Optional : true ,
ForceNew : true ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"restart" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "The restart policy for the container. Must be one of 'no', 'on-failure', 'always', 'unless-stopped'. Defaults to `no`." ,
2021-03-18 03:30:54 -04:00
Default : "no" ,
2021-05-21 08:30:56 -04:00
Optional : true ,
2021-03-18 03:30:54 -04:00
ValidateDiagFunc : validateStringMatchesPattern ( ` ^(no|on-failure|always|unless-stopped)$ ` ) ,
2015-10-27 12:08:57 -04:00
} ,
2019-03-01 16:02:17 -05:00
"max_retry_count" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The maximum amount of times to an attempt a restart when `restart` is set to 'on-failure'." ,
Optional : true ,
2015-10-27 12:08:57 -04:00
} ,
2020-02-01 10:15:36 -05:00
"working_dir" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The working directory for commands to run in." ,
Optional : true ,
ForceNew : true ,
2020-11-29 08:38:33 -05:00
DiffSuppressFunc : func ( k , oldV , newV string , d * schema . ResourceData ) bool {
// treat "" as a no-op, which is Docker's default behavior
if newV == "" {
newV = oldV
}
return oldV == newV
} ,
2019-09-23 13:41:20 -04:00
} ,
2020-10-11 09:25:20 -04:00
"remove_volumes" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, it will remove anonymous volumes associated with the container. Defaults to `true`." ,
Default : true ,
Optional : true ,
2020-10-11 09:25:20 -04:00
} ,
2019-03-01 16:02:17 -05:00
"capabilities" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Add or drop certrain linux capabilities." ,
Optional : true ,
ForceNew : true ,
MaxItems : 1 ,
2020-02-01 10:15:36 -05:00
// TODO implement DiffSuppressFunc
2017-03-07 11:48:20 -05:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"add" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "List of linux capabilities to add." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2017-03-07 11:48:20 -05:00
} ,
2019-03-01 16:02:17 -05:00
"drop" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "List of linux capabilities to drop." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2017-03-07 11:48:20 -05:00
} ,
} ,
} ,
} ,
2020-11-15 12:19:19 -05:00
"security_opts" : {
Type : schema . TypeSet ,
2021-05-21 08:30:56 -04:00
Description : "List of string values to customize labels for MLS systems, such as SELinux. See https://docs.docker.com/engine/reference/run/#security-configuration." ,
2020-11-15 12:19:19 -05:00
Optional : true ,
ForceNew : true ,
Computed : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
} ,
2022-07-11 06:27:47 -04:00
"runtime" : {
Type : schema . TypeString ,
Description : "Runtime to use for the container." ,
Optional : true ,
ForceNew : true ,
Computed : true ,
} ,
"stop_signal" : {
Type : schema . TypeString ,
Description : "Signal to stop a container (default `SIGTERM`)." ,
Optional : true ,
ForceNew : true ,
Computed : true ,
} ,
"stop_timeout" : {
Type : schema . TypeInt ,
Description : "Timeout (in seconds) to stop a container." ,
Optional : true ,
ForceNew : true ,
Computed : true ,
} ,
2019-05-26 05:59:29 -04:00
"mounts" : {
Type : schema . TypeSet ,
2021-05-21 08:30:56 -04:00
Description : "Specification for mounts to be added to containers created as part of the service." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
2020-12-01 08:04:07 -05:00
ForceNew : true ,
2019-05-26 05:59:29 -04:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"target" : {
Type : schema . TypeString ,
Description : "Container path" ,
Required : true ,
} ,
"source" : {
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "Mount source (e.g. a volume name, a host path)." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
} ,
"type" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
Description : "The mount type" ,
Required : true ,
ValidateDiagFunc : validateStringMatchesPattern ( ` ^(bind|volume|tmpfs)$ ` ) ,
2019-05-26 05:59:29 -04:00
} ,
"read_only" : {
Type : schema . TypeBool ,
2021-05-21 08:30:56 -04:00
Description : "Whether the mount should be read-only." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
} ,
"bind_options" : {
Type : schema . TypeList ,
2021-05-21 08:30:56 -04:00
Description : "Optional configuration for the bind type." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
MaxItems : 1 ,
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"propagation" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "A propagation mode with the value." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ValidateDiagFunc : validateStringMatchesPattern ( ` ^(private|rprivate|shared|rshared|slave|rslave)$ ` ) ,
2019-05-26 05:59:29 -04:00
} ,
} ,
} ,
} ,
"volume_options" : {
Type : schema . TypeList ,
2021-05-21 08:30:56 -04:00
Description : "Optional configuration for the volume type." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
MaxItems : 1 ,
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"no_copy" : {
Type : schema . TypeBool ,
2021-05-21 08:30:56 -04:00
Description : "Populate volume with data from the target." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
} ,
"labels" : {
2019-11-10 15:15:42 -05:00
Type : schema . TypeSet ,
2021-05-21 08:30:56 -04:00
Description : "User-defined key/value metadata." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
2019-11-10 15:15:42 -05:00
Elem : labelSchema ,
2019-05-26 05:59:29 -04:00
} ,
"driver_name" : {
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "Name of the driver to use to create the volume." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
} ,
"driver_options" : {
Type : schema . TypeMap ,
2021-05-21 08:30:56 -04:00
Description : "key/value map of driver specific options." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
} ,
} ,
} ,
} ,
"tmpfs_options" : {
Type : schema . TypeList ,
2021-05-21 08:30:56 -04:00
Description : "Optional configuration for the tmpfs type." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
2020-02-01 10:15:36 -05:00
ForceNew : true ,
2019-05-26 05:59:29 -04:00
MaxItems : 1 ,
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"size_bytes" : {
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "The size for the tmpfs mount in bytes." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
} ,
"mode" : {
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "The permission mode for the tmpfs mount in an integer." ,
2019-05-26 05:59:29 -04:00
Optional : true ,
} ,
} ,
} ,
} ,
} ,
} ,
} ,
2019-03-01 16:02:17 -05:00
"volumes" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Spec for mounting volumes in the container." ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"from_container" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The container where the volume is coming from." ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
2019-03-01 16:02:17 -05:00
"container_path" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The path in the container where the volume will be mounted." ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
2019-03-01 16:02:17 -05:00
"host_path" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "The path on the host where the volume is coming from." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ForceNew : true ,
ValidateDiagFunc : validateDockerContainerPath ( ) ,
2016-01-15 16:59:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"volume_name" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The name of the docker volume which should be mounted." ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
2019-03-01 16:02:17 -05:00
"read_only" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, this volume will be readonly. Defaults to `false`." ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
} ,
} ,
2015-02-17 11:28:33 -05:00
} ,
2019-05-26 05:59:29 -04:00
"tmpfs" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeMap ,
Description : "A map of container directories which should be replaced by `tmpfs mounts`, and their corresponding mount options." ,
Optional : true ,
2019-05-26 05:59:29 -04:00
} ,
2019-03-01 16:02:17 -05:00
"ports" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeList ,
Description : "Publish a container's port(s) to the host." ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"internal" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "Port within the container." ,
Required : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
2019-03-01 16:02:17 -05:00
"external" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "Port exposed out of the container. If not given a free random port `>= 32768` will be used." ,
Optional : true ,
Computed : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
2019-03-01 16:02:17 -05:00
"ip" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "IP address/mask that can access this port. Defaults to `0.0.0.0`." ,
Default : "0.0.0.0" ,
Optional : true ,
ForceNew : true ,
2019-03-07 04:15:42 -05:00
StateFunc : func ( val interface { } ) string {
// Empty IP assignments default to 0.0.0.0
if val . ( string ) == "" {
return "0.0.0.0"
}
return val . ( string )
} ,
2015-12-03 05:51:59 -05:00
} ,
2019-03-01 16:02:17 -05:00
"protocol" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Protocol that can be used over this port. Defaults to `tcp`." ,
Default : "tcp" ,
Optional : true ,
ForceNew : true ,
2015-12-03 05:51:59 -05:00
} ,
} ,
} ,
2019-03-05 09:55:17 -05:00
DiffSuppressFunc : suppressIfPortsDidNotChangeForMigrationV0ToV1 ( ) ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"host" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Additional hosts to add to the container." ,
Optional : true ,
ForceNew : true ,
2015-10-09 09:05:43 -04:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"ip" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "IP address this hostname should resolve to." ,
Required : true ,
ForceNew : true ,
2015-10-09 09:05:43 -04:00
} ,
2019-03-01 16:02:17 -05:00
"host" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Hostname to add" ,
Required : true ,
ForceNew : true ,
2018-04-20 05:35:49 -04:00
} ,
} ,
} ,
} ,
2019-03-01 16:02:17 -05:00
"ulimit" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Ulimit options to add." ,
Optional : true ,
ForceNew : true ,
2018-04-20 05:35:49 -04:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"name" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The name of the ulimit" ,
Required : true ,
ForceNew : true ,
2018-04-20 05:35:49 -04:00
} ,
2019-03-01 16:02:17 -05:00
"soft" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The soft limit" ,
Required : true ,
ForceNew : true ,
2018-04-20 05:35:49 -04:00
} ,
2019-03-01 16:02:17 -05:00
"hard" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The hard limit" ,
Required : true ,
ForceNew : true ,
2015-10-09 09:05:43 -04:00
} ,
} ,
} ,
2015-02-17 11:28:33 -05:00
} ,
2019-03-01 16:02:17 -05:00
"env" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Environment variables to set in the form of `KEY=VALUE`, e.g. `DEBUG=0`" ,
Optional : true ,
ForceNew : true ,
Computed : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2015-02-17 11:28:33 -05:00
} ,
2015-04-16 15:42:21 -04:00
2019-03-01 16:02:17 -05:00
"links" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Set of links for link based connectivity between containers that are running on the same host." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
Deprecated : "The --link flag is a legacy feature of Docker. It may eventually be removed." ,
2015-04-16 15:42:21 -04:00
} ,
2015-04-16 09:21:14 -04:00
2019-03-01 16:02:17 -05:00
"ip_address" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The IP address of the container." ,
Computed : true ,
Deprecated : "Use `network_data` instead. The IP address of the container's first network it." ,
2015-04-20 15:18:46 -04:00
} ,
2019-03-01 16:02:17 -05:00
"ip_prefix_length" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The IP prefix length of the container." ,
Computed : true ,
Deprecated : "Use `network_data` instead. The IP prefix length of the container as read from its NetworkSettings." ,
2015-04-20 15:18:46 -04:00
} ,
2019-03-01 16:02:17 -05:00
"gateway" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The network gateway of the container." ,
Computed : true ,
Deprecated : "Use `network_data` instead. The network gateway of the container as read from its NetworkSettings." ,
2015-04-20 15:18:46 -04:00
} ,
2019-03-01 16:02:17 -05:00
"bridge" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The network bridge of the container as read from its NetworkSettings." ,
Computed : true ,
2015-04-20 15:18:46 -04:00
} ,
2015-06-04 06:57:38 -04:00
2019-03-01 16:02:17 -05:00
"network_data" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeList ,
Description : "The data of the networks the container is connected to." ,
Computed : true ,
2018-10-25 01:21:48 -04:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"network_name" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The name of the network" ,
Computed : true ,
2018-10-25 01:21:48 -04:00
} ,
2019-03-01 16:02:17 -05:00
"ip_address" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The IP address of the container." ,
Computed : true ,
Deprecated : "Use `network_data` instead. The IP address of the container's first network it." ,
2018-10-25 01:21:48 -04:00
} ,
2019-03-01 16:02:17 -05:00
"ip_prefix_length" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The IP prefix length of the container." ,
Computed : true ,
Deprecated : "Use `network_data` instead. The IP prefix length of the container as read from its NetworkSettings." ,
2018-10-25 01:21:48 -04:00
} ,
2019-03-01 16:02:17 -05:00
"gateway" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The network gateway of the container." ,
Computed : true ,
Deprecated : "Use `network_data` instead. The network gateway of the container as read from its NetworkSettings." ,
2018-10-25 01:21:48 -04:00
} ,
2020-05-01 22:29:59 -04:00
"global_ipv6_address" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The IPV6 address of the container." ,
Computed : true ,
2020-05-01 22:29:59 -04:00
} ,
"global_ipv6_prefix_length" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "The IPV6 prefix length address of the container." ,
Computed : true ,
2020-05-01 22:29:59 -04:00
} ,
"ipv6_gateway" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The IPV6 gateway of the container." ,
Computed : true ,
2020-05-01 22:29:59 -04:00
} ,
2018-10-25 01:21:48 -04:00
} ,
} ,
} ,
2019-03-01 16:02:17 -05:00
"privileged" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, the container runs in privileged mode." ,
Optional : true ,
ForceNew : true ,
2015-06-04 06:57:38 -04:00
} ,
2015-10-27 19:53:49 -04:00
2019-03-01 16:02:17 -05:00
"devices" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Bind devices to the container." ,
Optional : true ,
ForceNew : true ,
2018-04-20 05:14:44 -04:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
2019-03-01 16:02:17 -05:00
"host_path" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The path on the host where the device is located." ,
Required : true ,
ForceNew : true ,
2018-04-20 05:14:44 -04:00
} ,
2019-03-01 16:02:17 -05:00
"container_path" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The path in the container where the device will be bound." ,
Optional : true ,
ForceNew : true ,
2018-04-20 05:14:44 -04:00
} ,
2019-03-01 16:02:17 -05:00
"permissions" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The cgroup permissions given to the container to access the device. Defaults to `rwm`." ,
Optional : true ,
ForceNew : true ,
2018-04-20 05:14:44 -04:00
} ,
} ,
} ,
} ,
2019-03-01 16:02:17 -05:00
"destroy_grace_seconds" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeInt ,
Description : "If defined will attempt to stop the container before destroying. Container will be destroyed after `n` seconds or on successful stop." ,
Optional : true ,
2016-07-11 11:03:02 -04:00
} ,
2019-03-01 16:02:17 -05:00
"labels" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "User-defined key/value metadata" ,
Optional : true ,
ForceNew : true ,
Computed : true ,
Elem : labelSchema ,
2015-11-03 15:20:58 -05:00
} ,
2019-03-01 16:02:17 -05:00
"memory" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "The memory limit for the container in MBs." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ValidateDiagFunc : validateIntegerGeqThan ( 0 ) ,
2015-10-27 19:53:49 -04:00
} ,
2019-03-01 16:02:17 -05:00
"memory_swap" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "The total memory limit (memory + swap) for the container in MBs. This setting may compute to `-1` after `terraform apply` if the target host doesn't support memory swap, when that is the case docker will use a soft limitation." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ValidateDiagFunc : validateIntegerGeqThan ( - 1 ) ,
2019-11-14 17:10:48 -05:00
} ,
"shm_size" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "Size of `/dev/shm` in MBs." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ForceNew : true ,
Computed : true ,
ValidateDiagFunc : validateIntegerGeqThan ( 0 ) ,
2019-11-14 17:10:48 -05:00
} ,
"cpu_shares" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "CPU shares (relative weight) for the container." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ValidateDiagFunc : validateIntegerGeqThan ( 0 ) ,
2019-11-14 17:10:48 -05:00
} ,
"cpu_set" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "A comma-separated list or hyphen-separated range of CPUs a container can use, e.g. `0-1`." ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ValidateDiagFunc : validateStringMatchesPattern ( ` ^\d+([,-]\d+)*$ ` ) ,
2019-11-14 17:10:48 -05:00
} ,
"log_driver" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
2021-11-30 01:51:49 -05:00
Description : "The logging driver to use for the container." ,
Computed : true ,
2021-05-21 08:30:56 -04:00
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"log_opts" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeMap ,
Description : "Key/value pairs to use as options for the logging driver." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"network_alias" : {
Type : schema . TypeSet ,
2021-05-21 08:30:56 -04:00
Description : "Set an alias for the container in all specified networks" ,
2019-11-14 17:10:48 -05:00
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2021-05-21 08:30:56 -04:00
Deprecated : "Use networks_advanced instead. Will be removed in v3.0.0" ,
2019-11-14 17:10:48 -05:00
} ,
"network_mode" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Network mode of the container." ,
Optional : true ,
ForceNew : true ,
2020-02-01 10:15:36 -05:00
DiffSuppressFunc : func ( k , oldV , newV string , d * schema . ResourceData ) bool {
// treat "" as "default", which is Docker's default value
if oldV == "" {
oldV = "default"
}
if newV == "" {
newV = "default"
}
return oldV == newV
} ,
2019-11-14 17:10:48 -05:00
} ,
"networks" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "ID of the networks in which the container is." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
Deprecated : "Use networks_advanced instead. Will be removed in v3.0.0" ,
2019-11-14 17:10:48 -05:00
} ,
"networks_advanced" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "The networks the container is attached to" ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"name" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
2022-08-01 07:22:15 -04:00
Description : "The name or id of the network to use. You can use `name` or `id` attribute from a `docker_network` resource." ,
2021-05-21 08:30:56 -04:00
Required : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"aliases" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "The network aliases of the container in the specific network." ,
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
2019-11-14 17:10:48 -05:00
} ,
"ipv4_address" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The IPV4 address of the container in the specific network." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"ipv6_address" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "The IPV6 address of the container in the specific network." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
} ,
} ,
} ,
"pid_mode" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "he PID (Process) Namespace mode for the container. Either `container:<name|id>` or `host`." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"userns_mode" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Sets the usernamespace mode for the container when usernamespace remapping option is enabled." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"upload" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeSet ,
Description : "Specifies files to upload to the container before starting it. Only one of `content` or `content_base64` can be set and at least one of them has to be set." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"content" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text. Conflicts with `content_base64` & `source`" ,
Optional : true ,
2019-11-14 17:10:48 -05:00
// This is intentional. The container is mutated once, and never updated later.
// New configuration forces a new deployment, even with the same binaries.
ForceNew : true ,
} ,
"content_base64" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for larger binary content such as the result of the `base64encode` interpolation function. See [here](https://github.com/terraform-providers/terraform-provider-docker/issues/48#issuecomment-374174588) for the reason. Conflicts with `content` & `source`" ,
2021-03-18 03:30:54 -04:00
Optional : true ,
ForceNew : true ,
ValidateDiagFunc : validateStringIsBase64Encoded ( ) ,
2019-11-14 17:10:48 -05:00
} ,
"file" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "Path to the file in the container where is upload goes to" ,
Required : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"executable" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, the file will be uploaded with user executable permission. Defaults to `false`." ,
Default : false ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
2020-02-03 15:44:46 -05:00
"source" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "A filename that references a file which will be uploaded as the object content. This allows for large file uploads that do not get stored in state. Conflicts with `content` & `content_base64`" ,
Optional : true ,
ForceNew : true ,
2020-02-03 15:44:46 -05:00
} ,
"source_hash" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeString ,
Description : "If using `source`, this will force an update if the file content has updated but the filename has not. " ,
Optional : true ,
ForceNew : true ,
2020-02-03 15:44:46 -05:00
} ,
2019-11-14 17:10:48 -05:00
} ,
} ,
} ,
"healthcheck" : {
Type : schema . TypeList ,
Description : "A test to perform to check that the container is healthy" ,
MaxItems : 1 ,
Optional : true ,
2020-11-29 08:42:55 -05:00
Computed : true ,
2019-11-14 17:10:48 -05:00
Elem : & schema . Resource {
Schema : map [ string ] * schema . Schema {
"test" : {
Type : schema . TypeList ,
2021-05-21 08:30:56 -04:00
Description : "Command to run to check health. For example, to run `curl -f localhost/health` set the command to be `[\"CMD\", \"curl\", \"-f\", \"localhost/health\"]`." ,
2019-11-14 17:10:48 -05:00
Required : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
} ,
"interval" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "Time between running the check (ms|s|m|h). Defaults to `0s`." ,
2021-03-18 03:30:54 -04:00
Default : "0s" ,
2021-05-21 08:30:56 -04:00
Optional : true ,
2021-03-18 03:30:54 -04:00
ValidateDiagFunc : validateDurationGeq0 ( ) ,
2019-11-14 17:10:48 -05:00
} ,
"timeout" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "Maximum time to allow one check to run (ms|s|m|h). Defaults to `0s`." ,
2021-03-18 03:30:54 -04:00
Default : "0s" ,
2021-05-21 08:30:56 -04:00
Optional : true ,
2021-03-18 03:30:54 -04:00
ValidateDiagFunc : validateDurationGeq0 ( ) ,
2019-11-14 17:10:48 -05:00
} ,
"start_period" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h). Defaults to `0s`." ,
2021-03-18 03:30:54 -04:00
Default : "0s" ,
2021-05-21 08:30:56 -04:00
Optional : true ,
2021-03-18 03:30:54 -04:00
ValidateDiagFunc : validateDurationGeq0 ( ) ,
2019-11-14 17:10:48 -05:00
} ,
"retries" : {
2021-03-18 03:30:54 -04:00
Type : schema . TypeInt ,
2021-05-21 08:30:56 -04:00
Description : "Consecutive failures needed to report unhealthy. Defaults to `0`." ,
2021-03-18 03:30:54 -04:00
Default : 0 ,
2021-05-21 08:30:56 -04:00
Optional : true ,
2021-03-18 03:30:54 -04:00
ValidateDiagFunc : validateIntegerGeqThan ( 0 ) ,
2019-11-14 17:10:48 -05:00
} ,
} ,
} ,
} ,
"sysctls" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeMap ,
Description : "A map of kernel parameters (sysctls) to set in the container." ,
Optional : true ,
ForceNew : true ,
2019-11-14 17:10:48 -05:00
} ,
"ipc_mode" : {
Type : schema . TypeString ,
2021-05-21 08:30:56 -04:00
Description : "IPC sharing mode for the container. Possible values are: `none`, `private`, `shareable`, `container:<name|id>` or `host`." ,
2019-11-14 17:10:48 -05:00
Optional : true ,
ForceNew : true ,
2020-02-01 10:15:36 -05:00
Computed : true ,
2019-11-14 17:10:48 -05:00
} ,
"group_add" : {
Type : schema . TypeSet ,
Description : "Additional groups for the container user" ,
2019-10-06 05:13:24 -04:00
Optional : true ,
ForceNew : true ,
Elem : & schema . Schema { Type : schema . TypeString } ,
Set : schema . HashString ,
} ,
2020-11-11 10:14:49 -05:00
"init" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "Configured whether an init process should be injected for this container. If unset this will default to the `dockerd` defaults." ,
Optional : true ,
Computed : true ,
2020-11-11 10:14:49 -05:00
} ,
2021-01-18 03:00:26 -05:00
"tty" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, allocate a pseudo-tty (`docker run -t`). Defaults to `false`." ,
Default : false ,
Optional : true ,
ForceNew : true ,
2021-01-18 03:00:26 -05:00
} ,
"stdin_open" : {
2021-05-21 08:30:56 -04:00
Type : schema . TypeBool ,
Description : "If `true`, keep STDIN open even if not attached (`docker run -i`). Defaults to `false`." ,
Default : false ,
Optional : true ,
ForceNew : true ,
2021-01-18 03:00:26 -05:00
} ,
2021-08-04 17:59:48 -04:00
"storage_opts" : {
Type : schema . TypeMap ,
Description : "Key/value pairs for the storage driver options, e.g. `size`: `120G`" ,
Optional : true ,
ForceNew : true ,
} ,
2022-07-15 05:15:28 -04:00
"gpus" : {
Type : schema . TypeString ,
Description : "GPU devices to add to the container. Currently, only the value `all` is supported. Passing any other value will result in unexpected behavior." ,
Optional : true ,
ForceNew : true ,
} ,
2015-02-17 11:28:33 -05:00
} ,
}
}
2019-03-05 09:55:17 -05:00
func suppressIfPortsDidNotChangeForMigrationV0ToV1 ( ) schema . SchemaDiffSuppressFunc {
return func ( k , old , new string , d * schema . ResourceData ) bool {
2019-08-01 18:16:50 -04:00
if k == "ports.#" && old != new {
log . Printf ( "[DEBUG] suppress diff ports: old and new don't have the same length" )
return false
}
2019-03-05 09:55:17 -05:00
portsOldRaw , portsNewRaw := d . GetChange ( "ports" )
portsOld := portsOldRaw . ( [ ] interface { } )
portsNew := portsNewRaw . ( [ ] interface { } )
if len ( portsOld ) != len ( portsNew ) {
log . Printf ( "[DEBUG] suppress diff ports: old and new don't have the same length" )
return false
}
log . Printf ( "[DEBUG] suppress diff ports: old and new have same length" )
for _ , portOld := range portsOld {
portOldMapped := portOld . ( map [ string ] interface { } )
oldInternalPort := portOldMapped [ "internal" ]
portFound := false
for _ , portNew := range portsNew {
portNewMapped := portNew . ( map [ string ] interface { } )
newInternalPort := portNewMapped [ "internal" ]
// port is still there in new
if newInternalPort == oldInternalPort {
log . Printf ( "[DEBUG] suppress diff ports: comparing port '%v'" , oldInternalPort )
2020-08-02 12:27:43 -04:00
if portNewMapped [ "protocol" ] != portOldMapped [ "protocol" ] {
if containsPortWithProtocol ( portsNew , portOldMapped [ "internal" ] , portOldMapped [ "protocol" ] ) {
log . Printf ( "[DEBUG] suppress diff ports: found another port in new list with the same protocol for '%v" , oldInternalPort )
continue
}
log . Printf ( "[DEBUG] suppress diff ports: 'protocol' changed for '%v'" , oldInternalPort )
return false
}
2019-03-05 09:55:17 -05:00
if portNewMapped [ "external" ] != portOldMapped [ "external" ] {
log . Printf ( "[DEBUG] suppress diff ports: 'external' changed for '%v'" , oldInternalPort )
return false
}
if portNewMapped [ "ip" ] != portOldMapped [ "ip" ] {
log . Printf ( "[DEBUG] suppress diff ports: 'ip' changed for '%v'" , oldInternalPort )
return false
}
2020-08-02 12:27:43 -04:00
portFound = true
break
2019-03-05 09:55:17 -05:00
}
}
// port was deleted or exchanges in new
if ! portFound {
log . Printf ( "[DEBUG] suppress diff ports: port was deleted '%v'" , oldInternalPort )
return false
}
}
return true
}
}
2020-08-02 12:27:43 -04:00
func containsPortWithProtocol ( ports [ ] interface { } , searchInternalPort , searchProtocol interface { } ) bool {
for _ , port := range ports {
portMapped := port . ( map [ string ] interface { } )
internalPort := portMapped [ "internal" ]
protocol := portMapped [ "protocol" ]
if internalPort == searchInternalPort && protocol == searchProtocol {
return true
}
}
return false
}