Documentation ¶
Index ¶
- Constants
- Variables
- func UnmarshalDistributionManifest(ctHeader string, p []byte) (DistributionManifest, Descriptor, error)
- type Config
- type ContainerConfig
- type Descriptor
- type Digest
- type DigestPair
- type DigestPairMap
- type DigestPairs
- type Digester
- type DistributionManifest
- type ExportConfig
- type ExportLayer
- type ExportManifest
- type Exporter
- type HealthConfig
- type History
- type ID
- type Name
- type RootFS
- type V1Image
Constants ¶
const ( // MediaTypeManifest specifies the mediaType for the current version. MediaTypeManifest = "application/vnd.docker.distribution.manifest.v2+json" // MediaTypeConfig specifies the mediaType for the image configuration. MediaTypeConfig = "application/vnd.docker.container.image.v1+json" // MediaTypeLayer is the mediaType used for layers referenced by the manifest. MediaTypeLayer = "application/vnd.docker.image.rootfs.diff.tar.gzip" )
const ( DockerHubRegistry = "index.docker.io" DockerHubNamespace = "library" Scratch = "scratch" )
Docker hub defaults.
const DigestEmptyTar = Digest("sha256:84ff92691f909a05b224e1c56abb4864f01b4f8e3c854e4bb4c7baf1d3f6d652")
DigestEmptyTar is the sha256 digest of an empty tar file (platform dependent).
const (
ExportManifestFileName = "manifest.json"
)
Name of files after untar a docker image
Variables ¶
var SHA256 = "sha256"
SHA256 is the only algorithm supported.
Functions ¶
func UnmarshalDistributionManifest ¶
func UnmarshalDistributionManifest(ctHeader string, p []byte) (DistributionManifest, Descriptor, error)
UnmarshalDistributionManifest verifies MediaType and unmarshals manifest.
Types ¶
type Config ¶
type Config struct { V1Image Parent ID `json:"parent,omitempty"` RootFS *RootFS `json:"rootfs,omitempty"` History []History `json:"history,omitempty"` // contains filtered or unexported fields }
Config stores the image configuration
func NewDefaultImageConfig ¶
func NewDefaultImageConfig() Config
NewDefaultImageConfig returns a default image config that is used for images built from scratch.
func NewImageConfigFromCopy ¶
NewImageConfigFromCopy returns a copy of given config.
func NewImageConfigFromJSON ¶
NewImageConfigFromJSON creates an Image configuration from json.
func (*Config) MarshalJSON ¶
MarshalJSON serializes the image to JSON. It sorts the top-level keys so that JSON that's been manipulated by a push/pull cycle with a legacy registry won't end up with a different key order.
type ContainerConfig ¶
type ContainerConfig struct { Hostname string // Hostname Domainname string // Domainname User string // User that will run the command(s) inside the container, also support user:group AttachStdin bool // Attach the standard input, makes possible user interaction AttachStdout bool // Attach the standard output AttachStderr bool // Attach the standard error ExposedPorts map[string]struct{} `json:",omitempty"` // List of exposed ports Tty bool // Attach standard streams to a tty, including stdin if it is not closed. OpenStdin bool // Open stdin StdinOnce bool // If true, close stdin after the 1 attached client disconnects. Env []string // List of environment variable to set in the container Cmd []string // Command to run when starting the container Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific) Image string // Name of the image as it was passed by the operator (eg. could be symbolic) Volumes map[string]struct{} // List of volumes (mounts) used for the container WorkingDir string // Current directory (PWD) in the command will be launched Entrypoint []string // Entrypoint to run when starting the container NetworkDisabled bool `json:",omitempty"` // Is network disabled MacAddress string `json:",omitempty"` // Mac Address of the container OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile Labels map[string]string // List of labels set to this container StopSignal string `json:",omitempty"` // Signal to stop a container StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container Shell []string `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT }
ContainerConfig contains the configuration about a container.
type Descriptor ¶
type Descriptor struct { // MediaType describe the type of the content. // All text based formats are encoded as utf-8. MediaType string `json:"mediaType,omitempty"` // Size in bytes of content. Size int64 `json:"size,omitempty"` // Digest uniquely identifies the content. Digest Digest `json:"digest,omitempty"` }
Descriptor describes targeted content.
func NewEmptyDescriptor ¶
func NewEmptyDescriptor() Descriptor
NewEmptyDescriptor returns a 0 value descriptor.
type Digest ¶
type Digest string
Digest is formatted like "<algorithm>:<hex_digest_string>" Example:
sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
type DigestPair ¶
type DigestPair struct { TarDigest Digest GzipDescriptor Descriptor }
DigestPair is a pair of uncompressed digest/compressed descriptor of the same layer. All layers in makisu are saved in gzipped format, and that value is used in distribution manifest; However the uncompressed digest is needed in image configs, so they are often passed around in pairs.
type DigestPairMap ¶ added in v0.1.1
type DigestPairMap map[string]DigestPairs
DigestPairMap is a map from string to DigestPairs
type DigestPairs ¶ added in v0.1.1
type DigestPairs []*DigestPair
DigestPairs is a list of DigestPair
type Digester ¶
type Digester struct {
// contains filtered or unexported fields
}
Digester calculates the digest of written data.
func NewDigester ¶
func NewDigester() *Digester
NewDigester instantiates and returns a new Digester object.
type DistributionManifest ¶
type DistributionManifest struct { // SchemaVersion is the image manifest schema that this image uses. SchemaVersion int `json:"schemaVersion"` // MediaType is the media type of this schema. MediaType string `json:"mediaType,omitempty"` // Config references the image configuration as a blob. Config Descriptor `json:"config"` // Layers lists descriptors for all referenced layers, starting from base layer. Layers []Descriptor `json:"layers"` }
DistributionManifest defines a schema2 manifest. It's used for docker pull and docker push.
func (DistributionManifest) GetConfigDigest ¶ added in v0.1.7
func (manifest DistributionManifest) GetConfigDigest() Digest
GetConfigDigest returns digest of the image config
func (DistributionManifest) GetLayerDigests ¶ added in v0.1.7
func (manifest DistributionManifest) GetLayerDigests() []Digest
GetLayerDigests returns the list of layer digests of the image.
type ExportConfig ¶
type ExportConfig string
ExportConfig is a string in the format <configID>.json
func (ExportConfig) String ¶
func (c ExportConfig) String() string
type ExportLayer ¶
type ExportLayer string
ExportLayer is a string in the format <layerID>/layer.tar
func (ExportLayer) String ¶
func (l ExportLayer) String() string
type ExportManifest ¶
type ExportManifest struct { Config ExportConfig RepoTags []string Layers []ExportLayer }
ExportManifest is used for docker load and docker save. It contains a list of layer IDs, image config ID, and <repo>:<tag>
func NewExportManifestFromDistribution ¶
func NewExportManifestFromDistribution(imageName Name, distribution DistributionManifest) ExportManifest
NewExportManifestFromDistribution creates ExportManifest given repo, tag and distrubtion manifest
type Exporter ¶
type Exporter interface { Load(io.ReadCloser, io.Writer, bool) error // TODO: Load(net.Context, io.ReadCloser, <- chan StatusMessage) error Save([]string, io.Writer) error }
Exporter provides interface for exporting and importing images.
type HealthConfig ¶
type HealthConfig struct { // Test is the test to perform to check that the container is healthy. // An empty slice means to inherit the default. // The options are: // {} : inherit healthcheck // {"NONE"} : disable healthcheck // {"CMD", args...} : exec arguments directly // {"CMD-SHELL", command} : run command with system's default shell Test []string `json:",omitempty"` // Zero means to inherit. Durations are expressed as integer nanoseconds. Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks. Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung. StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down. // Retries is the number of consecutive failures needed to consider a container as unhealthy. // Zero means inherit. Retries int `json:",omitempty"` }
HealthConfig holds configuration settings for the HEALTHCHECK feature.
type History ¶
type History struct { // Created timestamp for build point Created time.Time `json:"created"` // Author of the build point Author string `json:"author,omitempty"` // CreatedBy keeps the Dockerfile command used while building image. CreatedBy string `json:"created_by,omitempty"` // Comment is custom message set by the user when creating the image. Comment string `json:"comment,omitempty"` // EmptyLayer is set to true if this history item did not generate a // layer. Otherwise, the history item is associated with the next // layer in the RootFS section. EmptyLayer bool `json:"empty_layer,omitempty"` }
History stores build commands that were used to create an image.
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name is the identifier of an image
func MustParseName ¶
MustParseName calls ParseName on the input and panics if the parsing of the image name fails
func NewImageName ¶
NewImageName returns a new image name given a registry, repo and tag.
func ParseNameForPull ¶
ParseNameForPull parses image name of format <registry>/<repo>:<tag>. If input doesn't contain registry information, apply defaults for dockerhub.
func (Name) GetRegistry ¶
GetRegistry returns image repository
func (Name) GetRepository ¶
GetRepository returns image repository
func (Name) IsValid ¶
IsValid returns whether or not the image name is valid, that is, an image name needs to have a non-empty registry, repository and tag
func (Name) String ¶
String returns the full name of the image with the registry information if available
func (Name) WithRegistry ¶ added in v0.1.3
WithRegistry makes a copy of the image name and sets the registry.
type V1Image ¶
type V1Image struct { // ID a unique 64 character identifier of the image ID string `json:"id,omitempty"` // Parent id of the image Parent string `json:"parent,omitempty"` // Comment user added comment Comment string `json:"comment,omitempty"` // Created timestamp when image was created Created time.Time `json:"created"` // Container is the id of the container used to commit Container string `json:"container,omitempty"` // ContainerConfiguration is the configuration of the container that is committed into the image // It only contains history information. It should be safe to leave this field empty. ContainerConfiguration *ContainerConfig `json:"container_config,omitempty"` // DockerVersion specifies version on which image is built DockerVersion string `json:"docker_version,omitempty"` // Author of the image Author string `json:"author,omitempty"` // Config is the configuration of the container received from the client Config *ContainerConfig `json:"config,omitempty"` // Architecture is the hardware that the image is build and runs on Architecture string `json:"architecture,omitempty"` // OS is the operating system used to build and run the image OS string `json:"os,omitempty"` // Size is the total size of the image including all layers it is composed of Size int64 `json:",omitempty"` }
V1Image stores the V1 image configuration.