Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Add support for volume mounts #44

Open
groja opened this issue Feb 19, 2020 · 0 comments
Open

Add support for volume mounts #44

groja opened this issue Feb 19, 2020 · 0 comments

Comments

@groja
Copy link

groja commented Feb 19, 2020

Expected Behavior

It would be useful to be able to support volume mounts rather than just bind mounts, as it lets you use a wider variety of volume drivers.

Current Behavior

Only bind mounts are supported

Possible Solution

The following change to the code seems to work (I'm new to Go so feel free to suggest a better way of formatting it):
Old:

if len(parts) == 2 {
			mountVal := mount.Mount{
				Source: parts[0],
				Target: parts[1],
			}

			spec.TaskTemplate.ContainerSpec.Mounts = append(spec.TaskTemplate.ContainerSpec.Mounts, mountVal)
		}

New:

if len(parts) == 2 {
                        mountVal := mount.Mount{}
                        if strings.HasPrefix(parts[0], "v:") {
                                mountVal = mount.Mount{
                                        Type: mount.TypeVolume,
                                        Source: strings.TrimLeft(parts[0], "v:"),
                                        Target: parts[1],
                                }
                        } else {
                                mountVal = mount.Mount{
                                        Source: parts[0],
                                        Target: parts[1],
                                }
                        }
                        spec.TaskTemplate.ContainerSpec.Mounts = append(spec.TaskTemplate.ContainerSpec.Mounts, mountVal)
                }

Then, if I want to use a named volume pass in:

-m "v:volumeName=/mnt/somewhere"

Context

I want to use JaaS with persistent volumes created by the Docker Swarm Cloudstor drivers.

Your Environment

  • Version used: master
  • Environment name and version (e.g. Docker 1.13): Docker CE 19.03.5
  • Server type and version: Ubuntu 18.04LTS
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant