|
@@ -199,7 +199,7 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
|
|
|
cmd.Var(flVolumes, "v", "Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)")
|
|
|
|
|
|
var flVolumesFrom utils.ListOpts
|
|
|
- cmd.Var(&flVolumesFrom, "volumes-from", "Mount volumes from the specified container")
|
|
|
+ cmd.Var(&flVolumesFrom, "volumes-from", "Mount volumes from the specified container(s)")
|
|
|
|
|
|
flEntrypoint := cmd.String("entrypoint", "", "Overwrite the default entrypoint of the image")
|
|
|
|
|
@@ -749,9 +749,23 @@ func (container *Container) Start() (err error) {
|
|
|
|
|
|
// Apply volumes from another container if requested
|
|
|
if container.Config.VolumesFrom != "" {
|
|
|
- volumes := strings.Split(container.Config.VolumesFrom, ",")
|
|
|
- for _, v := range volumes {
|
|
|
- c := container.runtime.Get(v)
|
|
|
+ containerSpecs := strings.Split(container.Config.VolumesFrom, ",")
|
|
|
+ for _, containerSpec := range containerSpecs {
|
|
|
+ mountRW := true
|
|
|
+ specParts := strings.SplitN(containerSpec, ":", 2)
|
|
|
+ switch len(specParts) {
|
|
|
+ case 0:
|
|
|
+ return fmt.Errorf("Malformed volumes-from specification: %s", container.Config.VolumesFrom)
|
|
|
+ case 2:
|
|
|
+ switch specParts[1] {
|
|
|
+ case "ro":
|
|
|
+ mountRW = false
|
|
|
+ case "rw": // mountRW is already true
|
|
|
+ default:
|
|
|
+ return fmt.Errorf("Malformed volumes-from speficication: %s", containerSpec)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ c := container.runtime.Get(specParts[0])
|
|
|
if c == nil {
|
|
|
return fmt.Errorf("Container %s not found. Impossible to mount its volumes", container.ID)
|
|
|
}
|
|
@@ -764,7 +778,7 @@ func (container *Container) Start() (err error) {
|
|
|
}
|
|
|
container.Volumes[volPath] = id
|
|
|
if isRW, exists := c.VolumesRW[volPath]; exists {
|
|
|
- container.VolumesRW[volPath] = isRW
|
|
|
+ container.VolumesRW[volPath] = isRW && mountRW
|
|
|
}
|
|
|
}
|
|
|
|