Volume class
<!-- Bug: Type and Name are switched --> Creates and destroys a volume in Docker. This can be used alongside docker.Container to prepare volumes that can be shared across containers.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
const sharedVolume = new docker.Volume("shared_volume", {name: "shared_volume"});
import pulumi
import pulumi_docker as docker
shared_volume = docker.Volume("shared_volume", name="shared_volume")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
var sharedVolume = new Docker.Volume("shared_volume", new()
{
Name = "shared_volume",
});
});
package main
import (
"github.com/pulumi/pulumi-docker/sdk/v5/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := docker.NewVolume(ctx, "shared_volume", &docker.VolumeArgs{
Name: pulumi.String("shared_volume"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
docker = {
source = "pulumi/docker"
}
}
}
resource "docker_volume" "shared_volume" {
name = "shared_volume"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.docker.Volume;
import com.pulumi.docker.VolumeArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var sharedVolume = new Volume("sharedVolume", VolumeArgs.builder()
.name("shared_volume")
.build());
}
}
resources:
sharedVolume:
type: docker:Volume
name: shared_volume
properties:
name: shared_volume
Import
!/bin/bash
$ pulumi import docker:index/volume:Volume foo id
Example
Assuming you created a volume as follows
#!/bin/bash
docker volume create
# prints the long ID
524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d
you provide the definition for the resource as follows
import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker";
const foo = new docker.Volume("foo", {name: "524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d"});
import pulumi
import pulumi_docker as docker
foo = docker.Volume("foo", name="524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Docker = Pulumi.Docker;
return await Deployment.RunAsync(() =>
{
var foo = new Docker.Volume("foo", new()
{
Name = "524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d",
});
});
package main
import (
"github.com/pulumi/pulumi-docker/sdk/v5/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := docker.NewVolume(ctx, "foo", &docker.VolumeArgs{
Name: pulumi.String("524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
docker = {
source = "pulumi/docker"
}
}
}
resource "docker_volume" "foo" {
name = "524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.docker.Volume;
import com.pulumi.docker.VolumeArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var foo = new Volume("foo", VolumeArgs.builder()
.name("524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d")
.build());
}
}
resources:
foo:
type: docker:Volume
properties:
name: 524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d
then the import command is as follows
!/bin/bash
$ pulumi import docker:index/volume:Volume foo 524b0457aa2a87dd2b75c74c3e4e53f406974249e63ab3ed9bf21e5644f9dc7d
Constructors
- Volume(String name, {VolumeArgs? args, CustomResourceOptions? options})
-
Creates a new Volume.
nameThe Pulumi resource name.argsArguments used to configure this Volume. The set of arguments for Volume.optionsResource options controlling this resource's behavior. - Volume.reference(String urn)
- Creates a typed reference to an existing Volume resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
cluster
↔ Output<
VolumeCluster?> -
Cluster-specific options for volume creation. Only works if the Docker daemon is running in swarm mode and is the swarm manager.
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
driver
↔ Output<
String> -
Driver type for the volume. Defaults to
local.latefinal -
driverOpts
↔ Output<
Map< String, String> ?> -
Options specific to the driver.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
labels
↔ Output<
List< VolumeLabel> ?> -
User-defined key/value metadata
latefinal
-
mountpoint
↔ Output<
String> -
The mountpoint of the volume.
latefinal
-
name
↔ Output<
String> -
The name of the Docker volume (will be generated if not provided).
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited