mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
c985302c5c
When a container is restarted all the volume configs are parsed again. Even if the volume was already handled in a previous start it was still calling "FindOrCreateVolume" on the volume repo causing a new volume to be created. This wasn't being detected because as part of the mount initialization it checks to see if the the _mount_ was already initialized, but this happens after the parsing of the configs. So a check is added during parsing to skip a volume which was already created for that container. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
45 lines
1 KiB
Go
45 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
var (
|
|
// the docker binary to use
|
|
dockerBinary = "docker"
|
|
|
|
// the private registry image to use for tests involving the registry
|
|
registryImageName = "registry"
|
|
|
|
// the private registry to use for tests
|
|
privateRegistryURL = "127.0.0.1:5000"
|
|
|
|
execDriverPath = "/var/lib/docker/execdriver/native"
|
|
volumesConfigPath = "/var/lib/docker/volumes"
|
|
|
|
workingDirectory string
|
|
)
|
|
|
|
func init() {
|
|
if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
|
|
dockerBinary = dockerBin
|
|
} else {
|
|
whichCmd := exec.Command("which", "docker")
|
|
out, _, err := runCommandWithOutput(whichCmd)
|
|
if err == nil {
|
|
dockerBinary = stripTrailingCharacters(out)
|
|
} else {
|
|
fmt.Printf("ERROR: couldn't resolve full path to the Docker binary")
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
|
|
registryImageName = registryImage
|
|
}
|
|
if registry := os.Getenv("REGISTRY_URL"); registry != "" {
|
|
privateRegistryURL = registry
|
|
}
|
|
workingDirectory, _ = os.Getwd()
|
|
}
|