summaryrefslogtreecommitdiff
path: root/cmd/podman/spec.go
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-02-16 10:38:12 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-22 15:14:00 +0000
commit3d395767d8c3e467e784e3836c7175f6d11931a7 (patch)
treea64044df96164ad10873ad5a642e576b99b33bdd /cmd/podman/spec.go
parent7a7a6c2d79ebd831acf0321643903136dca7c2cb (diff)
downloadpodman-3d395767d8c3e467e784e3836c7175f6d11931a7.tar.gz
podman-3d395767d8c3e467e784e3836c7175f6d11931a7.tar.bz2
podman-3d395767d8c3e467e784e3836c7175f6d11931a7.zip
Implement --image-volumes for create and run
--image-volumes tells podman what to do with the image volumes in the image config There are 3 options: bind, tmpfs, and ignore bind puts the volume contents in /var/lib/containers/storage/container-id/volumes/vol-dir and bind mounts it into the container at /vol-dir tmpfs mounts /vol-dir as a tmps into the container ignore doesn't mount the image volumes onto the container Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #377 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/spec.go')
-rw-r--r--cmd/podman/spec.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/cmd/podman/spec.go b/cmd/podman/spec.go
index e78118b2f..2c2005399 100644
--- a/cmd/podman/spec.go
+++ b/cmd/podman/spec.go
@@ -351,7 +351,7 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) {
}
// BIND MOUNTS
- mounts, err := config.GetVolumeMounts()
+ mounts, err := config.GetVolumeMounts(configSpec.Mounts)
if err != nil {
return nil, errors.Wrapf(err, "error getting volume mounts")
}
@@ -500,7 +500,7 @@ func getDefaultAnnotations() map[string]string {
}
//GetVolumeMounts takes user provided input for bind mounts and creates Mount structs
-func (c *createConfig) GetVolumeMounts() ([]spec.Mount, error) {
+func (c *createConfig) GetVolumeMounts(specMounts []spec.Mount) ([]spec.Mount, error) {
var m []spec.Mount
var options []string
for _, i := range c.Volumes {
@@ -509,6 +509,9 @@ func (c *createConfig) GetVolumeMounts() ([]spec.Mount, error) {
if len(spliti) > 2 {
options = strings.Split(spliti[2], ",")
}
+ if libpod.MountExists(specMounts, spliti[1]) {
+ continue
+ }
options = append(options, "rbind")
var foundrw, foundro, foundz, foundZ bool
var rootProp string
@@ -550,6 +553,23 @@ func (c *createConfig) GetVolumeMounts() ([]spec.Mount, error) {
Options: options,
})
}
+
+ // volumes from image config
+ if c.ImageVolumeType != "tmpfs" {
+ return m, nil
+ }
+ for vol := range c.BuiltinImgVolumes {
+ if libpod.MountExists(specMounts, vol) {
+ continue
+ }
+ mount := spec.Mount{
+ Destination: vol,
+ Type: string(TypeTmpfs),
+ Source: string(TypeTmpfs),
+ Options: []string{"rw", "noexec", "nosuid", "nodev", "tmpcopyup"},
+ }
+ m = append(m, mount)
+ }
return m, nil
}