Beispiel #1
0
func (c *Container) parseService() {
	if c.requiresSyslog() {
		c.addLink("syslog")
		log.Infof("[%v]: Implicitly linked to 'syslog'", c.Name)
	}

	if c.requiresUserDocker() {
		c.addLink("dockerwait")
		log.Infof("[%v]: Implicitly linked to 'dockerwait'", c.Name)
	} else if c.ContainerCfg.Service.Image != "" {
		client, err := NewClient(c.dockerHost)
		if err != nil {
			c.Err = err
			return
		}

		i, _ := client.InspectImage(c.ContainerCfg.Service.Image)
		if i == nil {
			c.addLink("network")
			log.Infof("[%v]: Implicitly linked to 'network'", c.Name)
		}
	}

	cfg, hostConfig, err := docker.Convert(c.ContainerCfg.Service)
	if err != nil {
		c.Err = err
		return
	}

	c.Config = cfg
	c.HostConfig = hostConfig

	c.detach = c.Config.Labels[config.DETACH] != "false"
	c.remove = c.Config.Labels[config.REMOVE] != "false"
	c.ContainerCfg.CreateOnly = c.Config.Labels[config.CREATE_ONLY] == "true"
	c.ContainerCfg.ReloadConfig = c.Config.Labels[config.RELOAD_CONFIG] == "true"
}
Beispiel #2
0
func (r *RancherService) createLaunchConfig(serviceConfig *project.ServiceConfig) (rancherClient.LaunchConfig, error) {
	var result rancherClient.LaunchConfig

	schemasUrl := strings.SplitN(r.context.Client.Schemas.Links["self"], "/schemas", 2)[0]
	scriptsUrl := schemasUrl + "/scripts/transform"

	config, hostConfig, err := docker.Convert(serviceConfig)
	if err != nil {
		return result, err
	}

	dockerContainer := &ContainerInspect{
		Config:     config,
		HostConfig: hostConfig,
	}

	dockerContainer.HostConfig.NetworkMode = runconfig.NetworkMode("")

	if serviceConfig.Name != "" {
		dockerContainer.Name = "/" + serviceConfig.Name
	} else {
		dockerContainer.Name = "/" + r.name
	}

	err = r.context.Client.Post(scriptsUrl, dockerContainer, &result)
	if err != nil {
		return result, err
	}

	result.HealthCheck = r.getHealthCheck()

	setupNetworking(serviceConfig.Net, &result)
	setupVolumesFrom(serviceConfig.VolumesFrom, &result)

	err = r.setupBuild(&result, serviceConfig)
	return result, err
}