Commit 5389ca5a authored by Zander Baldwin's avatar Zander Baldwin Committed by Zander Baldwin

Add VolumesFrom Option on Register

Add the option to specify a data container (on the host) for build containers on the registration of a docker runner, merging it with the list of cache volumes-from.
parent a39f759d
Pipeline #85720 failed with stage
......@@ -91,6 +91,7 @@ func (s *RegistrationContext) askForDockerService(service string, dockerConfig *
func (s *RegistrationContext) askDocker(runnerConfig *common.RunnerConfig) {
dockerConfig := &common.DockerConfig{}
dockerConfig.Image = s.ask("docker-image", "Please enter the Docker image (eg. ruby:2.1):")
dockerConfig.VolumesFrom = s.ask("docker-volumes-from", "Please enter the name of the data container, if any, to use volumes from:")
dockerConfig.Privileged = s.Bool("docker-privileged")
if s.askForDockerService("mysql", dockerConfig) {
......@@ -316,6 +317,11 @@ func init() {
Usage: "Run Docker containers in privileged mode (INSECURE)",
EnvVar: "DOCKER_PRIVILEGED",
},
cli.StringFlag{
Name: "docker-volumes-from",
Usage: "Use volumes from a data container",
EnvVar: "DOCKER_VOLUMES_FROM"
},
cli.StringFlag{
Name: "docker-mysql",
Usage: "MySQL version (or specify latest) to link as service Docker service",
......
......@@ -23,6 +23,7 @@ type DockerConfig struct {
Privileged bool `toml:"privileged" json:"privileged"`
DisableCache *bool `toml:"disable_cache" json:"disable_cache"`
Volumes []string `toml:"volumes" json:"volumes"`
VolumesFrom []string `toml:"volumes_from" json:"volumes_from"`
CacheDir *string `toml:"cache_dir" json:"cache_dir"`
ExtraHosts []string `toml:"extra_hosts" json:"extra_hosts"`
Links []string `toml:"links" json:"links"`
......
......@@ -479,7 +479,7 @@ func (s *DockerExecutor) createContainer(image *docker.Image, cmd []string) (*do
return nil, err
}
createContainerOptions.HostConfig.Binds = binds
createContainerOptions.HostConfig.VolumesFrom = volumesFrom
createContainerOptions.HostConfig.VolumesFrom = append(volumesFrom, s.Config.Docker.VolumesFrom...)
s.Debugln("Creating container", createContainerOptions.Name, "...")
container, err := s.client.CreateContainer(createContainerOptions)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment