當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Service.Image方法代碼示例

本文整理匯總了Golang中github.com/eris-ltd/eris-cli/definitions.Service.Image方法的典型用法代碼示例。如果您正苦於以下問題:Golang Service.Image方法的具體用法?Golang Service.Image怎麽用?Golang Service.Image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/eris-ltd/eris-cli/definitions.Service的用法示例。


在下文中一共展示了Service.Image方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: configureDataContainer

func configureDataContainer(srv *def.Service, ops *def.Operation, mainContOpts *docker.CreateContainerOptions) (docker.CreateContainerOptions, error) {
	// by default data containers will rely on the image used by
	//   the base service. sometimes, tho, especially for testing
	//   that base image will not be present. in such cases use
	//   the base eris data container.
	if srv.Image == "" {
		srv.Image = "eris/data"
	}

	opts := docker.CreateContainerOptions{
		Name: ops.DataContainerName,
		Config: &docker.Config{
			Image:           srv.Image,
			User:            srv.User,
			AttachStdin:     false,
			AttachStdout:    false,
			AttachStderr:    false,
			Tty:             false,
			OpenStdin:       false,
			NetworkDisabled: true, // data containers do not need to talk to the outside world.
			Entrypoint:      []string{},
			Cmd:             []string{"false"}, // just gracefully exit. data containers just need to "exist" not run.
		},
		HostConfig: &docker.HostConfig{},
	}

	if mainContOpts != nil {
		mainContOpts.HostConfig.VolumesFrom = append(mainContOpts.HostConfig.VolumesFrom, ops.DataContainerName)
	}

	return opts, nil
}
開發者ID:jumanjiman,項目名稱:eris-cli,代碼行數:32,代碼來源:docker_run.go

示例2: configureDataContainer

func configureDataContainer(srv *def.Service, ops *def.Operation, mainContOpts *docker.CreateContainerOptions) (docker.CreateContainerOptions, error) {
	// by default data containers will rely on the image used by
	//   the base service. sometimes, tho, especially for testing
	//   that base image will not be present. in such cases use
	//   the base eris data container.
	if srv.Image == "" {
		srv.Image = "quay.io/eris/data"
	}

	// Manipulate labels locally.
	labels := make(map[string]string)
	for k, v := range ops.Labels {
		labels[k] = v
	}

	// If connected to a service.
	if mainContOpts != nil {
		// Set the service container's VolumesFrom pointing to the data container.
		mainContOpts.HostConfig.VolumesFrom = append(mainContOpts.HostConfig.VolumesFrom, ops.DataContainerName)

		// Operations are inherited from the service container.
		labels = util.SetLabel(labels, def.LabelType, def.TypeData)

		// Set the data container service label pointing to the service.
		labels = util.SetLabel(labels, def.LabelService, mainContOpts.Name)
	}

	opts := docker.CreateContainerOptions{
		Name: ops.DataContainerName,
		Config: &docker.Config{
			Image:        srv.Image,
			User:         srv.User,
			AttachStdin:  false,
			AttachStdout: false,
			AttachStderr: false,
			Tty:          false,
			OpenStdin:    false,
			Labels:       labels,

			// Data containers do not need to talk to the outside world.
			NetworkDisabled: true,

			// Just gracefully exit. Data containers just need to "exist" not run.
			Entrypoint: []string{"true"},
			Cmd:        []string{},
		},
		HostConfig: &docker.HostConfig{},
	}

	return opts, nil
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:51,代碼來源:docker_run.go


注:本文中的github.com/eris-ltd/eris-cli/definitions.Service.Image方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。