Have Docker create a missing volume host path (closes #235)
Check / check (pull_request) Skipped
Check / check (pull_request) Skipped
Docker refused to bind-mount a host path that did not exist, so an app's first deploy failed until someone ran mkdir on the host. buildMounts now sets BindOptions.CreateMountpoint on every bind mount, so the Docker daemon creates a missing host path when the container starts and leaves an existing one alone. upaas itself cannot create it: it runs in a container and does not see the host's filesystem. The README gains a Volume mounts section saying so. Model: opus-5-5
This commit is contained in:
@@ -222,7 +222,9 @@ func buildEnvSlice(env map[string]string) []string {
|
||||
return envSlice
|
||||
}
|
||||
|
||||
// buildMounts converts volume mounts to Docker mount configuration.
|
||||
// buildMounts converts volume mounts to Docker mount configuration. Docker,
|
||||
// not upaas, creates a missing host path, because upaas runs in a container
|
||||
// and cannot see the host's filesystem. An existing path is left alone.
|
||||
func buildMounts(volumes []VolumeMount) []mount.Mount {
|
||||
mounts := make([]mount.Mount, 0, len(volumes))
|
||||
|
||||
@@ -232,6 +234,9 @@ func buildMounts(volumes []VolumeMount) []mount.Mount {
|
||||
Source: vol.HostPath,
|
||||
Target: vol.ContainerPath,
|
||||
ReadOnly: vol.ReadOnly,
|
||||
BindOptions: &mount.BindOptions{
|
||||
CreateMountpoint: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user