github.com/kobeld/docker@v1.12.0-rc1/libcontainerd/windowsoci/oci_windows.go (about)

     1  package windowsoci
     2  
     3  // This file contains the Windows spec for a container. At the time of
     4  // writing, Windows does not have a spec defined in opencontainers/specs,
     5  // hence this is an interim workaround. TODO Windows: FIXME @jhowardmsft
     6  
     7  import "fmt"
     8  
     9  // WindowsSpec is the full specification for Windows containers.
    10  type WindowsSpec struct {
    11  	Spec
    12  
    13  	// Windows is platform specific configuration for Windows based containers.
    14  	Windows Windows `json:"windows"`
    15  }
    16  
    17  // Spec is the base configuration for the container.  It specifies platform
    18  // independent configuration. This information must be included when the
    19  // bundle is packaged for distribution.
    20  type Spec struct {
    21  
    22  	// Version is the version of the specification that is supported.
    23  	Version string `json:"ociVersion"`
    24  	// Platform is the host information for OS and Arch.
    25  	Platform Platform `json:"platform"`
    26  	// Process is the container's main process.
    27  	Process Process `json:"process"`
    28  	// Root is the root information for the container's filesystem.
    29  	Root Root `json:"root"`
    30  	// Hostname is the container's host name.
    31  	Hostname string `json:"hostname,omitempty"`
    32  	// Mounts profile configuration for adding mounts to the container's filesystem.
    33  	Mounts []Mount `json:"mounts"`
    34  }
    35  
    36  // Windows contains platform specific configuration for Windows based containers.
    37  type Windows struct {
    38  	// Resources contain information for handling resource constraints for the container
    39  	Resources *Resources `json:"resources,omitempty"`
    40  	// Networking contains the platform specific network settings for the container.
    41  	Networking *Networking `json:"networking,omitempty"`
    42  	// FirstStart is used for an optimization on first boot of Windows
    43  	FirstStart bool `json:"first_start,omitempty"`
    44  	// LayerFolder is the path to the current layer folder
    45  	LayerFolder string `json:"layer_folder,omitempty"`
    46  	// Layer paths of the parent layers
    47  	LayerPaths []string `json:"layer_paths,omitempty"`
    48  	// HvRuntime contains settings specific to Hyper-V containers, omitted if not using Hyper-V isolation
    49  	HvRuntime *HvRuntime `json:"hv_runtime,omitempty"`
    50  }
    51  
    52  // Process contains information to start a specific application inside the container.
    53  type Process struct {
    54  	// Terminal indicates if stderr should NOT be attached for the container.
    55  	Terminal bool `json:"terminal"`
    56  	// ConsoleSize contains the initial h,w of the console size
    57  	InitialConsoleSize [2]int `json:"-"`
    58  	// User specifies user information for the process.
    59  	User User `json:"user"`
    60  	// Args specifies the binary and arguments for the application to execute.
    61  	Args []string `json:"args"`
    62  	// Env populates the process environment for the process.
    63  	Env []string `json:"env,omitempty"`
    64  	// Cwd is the current working directory for the process and must be
    65  	// relative to the container's root.
    66  	Cwd string `json:"cwd"`
    67  }
    68  
    69  // User contains the user information for Windows
    70  type User struct {
    71  	User string `json:"user,omitempty"`
    72  }
    73  
    74  // Root contains information about the container's root filesystem on the host.
    75  type Root struct {
    76  	// Path is the absolute path to the container's root filesystem.
    77  	Path string `json:"path"`
    78  	// Readonly makes the root filesystem for the container readonly before the process is executed.
    79  	Readonly bool `json:"readonly"`
    80  }
    81  
    82  // Platform specifies OS and arch information for the host system that the container
    83  // is created for.
    84  type Platform struct {
    85  	// OS is the operating system.
    86  	OS string `json:"os"`
    87  	// Arch is the architecture
    88  	Arch string `json:"arch"`
    89  	// OSVersion is the version of the operating system.
    90  	OSVersion string `json:"os.version,omitempty"`
    91  }
    92  
    93  // Mount specifies a mount for a container.
    94  type Mount struct {
    95  	// Destination is the path where the mount will be placed relative to the container's root.  The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point.
    96  	Destination string `json:"destination"`
    97  	// Type specifies the mount kind.
    98  	Type string `json:"type"`
    99  	// Source specifies the source path of the mount.  In the case of bind mounts
   100  	// this would be the file on the host.
   101  	Source string `json:"source"`
   102  	// Readonly specifies if the mount should be read-only
   103  	Readonly bool `json:"readonly"`
   104  }
   105  
   106  // HvRuntime contains settings specific to Hyper-V containers
   107  type HvRuntime struct {
   108  	// ImagePath is the path to the Utility VM image for this container
   109  	ImagePath string `json:"image_path,omitempty"`
   110  }
   111  
   112  // Networking contains the platform specific network settings for the container
   113  type Networking struct {
   114  	// List of endpoints to be attached to the container
   115  	EndpointList []string `json:"endpoints,omitempty"`
   116  }
   117  
   118  // Storage contains storage resource management settings
   119  type Storage struct {
   120  	// Specifies maximum Iops for the system drive
   121  	Iops *uint64 `json:"iops,omitempty"`
   122  	// Specifies maximum bytes per second for the system drive
   123  	Bps *uint64 `json:"bps,omitempty"`
   124  	// Sandbox size indicates the size to expand the system drive to if it is currently smaller
   125  	SandboxSize *uint64 `json:"sandbox_size,omitempty"`
   126  }
   127  
   128  // Memory contains memory settings for the container
   129  type Memory struct {
   130  	// Memory limit (in bytes).
   131  	Limit *int64 `json:"limit,omitempty"`
   132  	// Memory reservation (in bytes).
   133  	Reservation *uint64 `json:"reservation,omitempty"`
   134  }
   135  
   136  // CPU contains information for cpu resource management
   137  type CPU struct {
   138  	// Number of CPUs available to the container. This is an appoximation for Windows Server Containers.
   139  	Count *uint64 `json:"count,omitempty"`
   140  	// CPU shares (relative weight (ratio) vs. other containers with cpu shares). Range is from 1 to 10000.
   141  	Shares *uint64 `json:"shares,omitempty"`
   142  	// Percent of available CPUs usable by the container.
   143  	Percent *int64 `json:"percent,omitempty"`
   144  }
   145  
   146  // Network network resource management information
   147  type Network struct {
   148  	// Bandwidth is the maximum egress bandwidth in bytes per second
   149  	Bandwidth *uint64 `json:"bandwidth,omitempty"`
   150  }
   151  
   152  // Resources has container runtime resource constraints
   153  // TODO Windows containerd. This structure needs ratifying with the old resources
   154  // structure used on Windows and the latest OCI spec.
   155  type Resources struct {
   156  	// Memory restriction configuration
   157  	Memory *Memory `json:"memory,omitempty"`
   158  	// CPU resource restriction configuration
   159  	CPU *CPU `json:"cpu,omitempty"`
   160  	// Storage restriction configuration
   161  	Storage *Storage `json:"storage,omitempty"`
   162  	// Network restriction configuration
   163  	Network *Network `json:"network,omitempty"`
   164  }
   165  
   166  const (
   167  	// VersionMajor is for an API incompatible changes
   168  	VersionMajor = 0
   169  	// VersionMinor is for functionality in a backwards-compatible manner
   170  	VersionMinor = 3
   171  	// VersionPatch is for backwards-compatible bug fixes
   172  	VersionPatch = 0
   173  
   174  	// VersionDev indicates development branch. Releases will be empty string.
   175  	VersionDev = ""
   176  )
   177  
   178  // Version is the specification version that the package types support.
   179  var Version = fmt.Sprintf("%d.%d.%d%s (Windows)", VersionMajor, VersionMinor, VersionPatch, VersionDev)