diff options
author | Evan Hazlett <ejhazlett@gmail.com> | 2016-10-19 12:22:02 -0400 |
---|---|---|
committer | Evan Hazlett <ejhazlett@gmail.com> | 2016-11-09 14:27:43 -0500 |
commit | 3716ec25b423d8ff7dfa231a7b3cf0154726ed37 (patch) | |
tree | 1df124c81f9b82059bb7fcf98c5b19f9bfad2a8e /container | |
parent | 1310dadf4ab3f38b346d78a6cbc7dae045388013 (diff) | |
download | docker-3716ec25b423d8ff7dfa231a7b3cf0154726ed37.tar.gz |
secrets: secret management for swarm
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
wip: use tmpfs for swarm secrets
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
wip: inject secrets from swarm secret store
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
secrets: use secret names in cli for service create
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
switch to use mounts instead of volumes
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
vendor: use ehazlett swarmkit
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
secrets: finish secret update
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
Diffstat (limited to 'container')
-rw-r--r-- | container/container.go | 5 | ||||
-rw-r--r-- | container/container_unix.go | 29 |
2 files changed, 31 insertions, 3 deletions
diff --git a/container/container.go b/container/container.go index 722271be96..74d080d46c 100644 --- a/container/container.go +++ b/container/container.go @@ -89,8 +89,9 @@ type CommonContainer struct { HasBeenStartedBefore bool HasBeenManuallyStopped bool // used for unless-stopped restart policy MountPoints map[string]*volume.MountPoint - HostConfig *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable - ExecCommands *exec.Store `json:"-"` + HostConfig *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable + ExecCommands *exec.Store `json:"-"` + Secrets []*containertypes.ContainerSecret `json:"-"` // do not serialize // logDriver for closing LogDriver logger.Logger `json:"-"` LogCopier *logger.Copier `json:"-"` diff --git a/container/container_unix.go b/container/container_unix.go index c38f750667..099073b83e 100644 --- a/container/container_unix.go +++ b/container/container_unix.go @@ -23,7 +23,10 @@ import ( ) // DefaultSHMSize is the default size (64MB) of the SHM which will be mounted in the container -const DefaultSHMSize int64 = 67108864 +const ( + DefaultSHMSize int64 = 67108864 + containerSecretMountPath = "/run/secrets" +) // Container holds the fields specific to unixen implementations. // See CommonContainer for standard fields common to all containers. @@ -175,6 +178,10 @@ func (container *Container) NetworkMounts() []Mount { return mounts } +func (container *Container) SecretMountPath() string { + return filepath.Join(container.Root, "secrets") +} + // CopyImagePathContent copies files in destination to the volume. func (container *Container) CopyImagePathContent(v volume.Volume, destination string) error { rootfs, err := symlink.FollowSymlinkInScope(filepath.Join(container.BaseFS, destination), container.BaseFS) @@ -260,6 +267,26 @@ func (container *Container) IpcMounts() []Mount { return mounts } +// SecretMounts returns the list of Secret mounts +func (container *Container) SecretMounts() []Mount { + var mounts []Mount + + if len(container.Secrets) > 0 { + mounts = append(mounts, Mount{ + Source: container.SecretMountPath(), + Destination: containerSecretMountPath, + Writable: false, + }) + } + + return mounts +} + +// UnmountSecrets unmounts the local tmpfs for secrets +func (container *Container) UnmountSecrets() error { + return detachMounted(container.SecretMountPath()) +} + // UpdateContainer updates configuration of a container. func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error { container.Lock() |