libsquash

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2014 License: MIT Imports: 14 Imported by: 0

README

libsquash

Library

GoDoc

This is based on jwilder/docker-squash, but the squashing functionality is extracted into a package named libsquash

libsquash is different from docker-squash in that libsquash...

  1. does not write to disk
  2. does not require sudo
  3. does not depend on the installation of any particular version of tar (or any version at all)

Other information:

Binary

Installation
go get github.com/winchman/libsquash/docker-squash
Usage

docker-squash works by squashing a saved image and loading the squashed image back into docker.

$ docker save <image id> > image.tar
$ sudo docker-squash -i image.tar -o squashed.tar
$ cat squashed.tar | docker load
$ docker images <new image id>

You can also tag the squashed image:

$ docker save <image id> > image.tar
$ sudo docker-squash -i image.tar -o squashed.tar -t newtag
$ cat squashed.tar | docker load
$ docker images <new image id>

You can reduce disk IO by piping the input and output to and from docker:

$ docker save <image id> | sudo docker-squash -t newtag | docker load

If you have a sufficient amount of RAM, you can also use a tmpfs to remove temporary disk storage:

$ docker save <image_id> | sudo TMPDIR=/var/run/shm docker-squash -t newtag | docker load

By default, a squashed layer is inserted after the first FROM layer. You can specify a different layer with the -from argument.

$ docker save <image_id> | sudo docker-squash -from <other layer> -t newtag | docker load

If you are creating a base image or only want one final squashed layer, you can use the -from root to squash the base layer and your changes into one layer.

$ docker save <image_id> | sudo docker-squash -from root -t newtag | docker load

Known Issues

Currently, squashing an image may remove or invalidate the ENTRYPOINT and CMD layers - they may need to be specified on the command line when running the image.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Verbose bool

Functions

func Squash

func Squash(inStream io.Reader) (io.Reader, error)

Types

type Config

type Config struct {
	Hostname        string
	Domainname      string
	User            string
	Memory          int64
	MemorySwap      int64
	CpuShares       int64
	AttachStdin     bool
	AttachStdout    bool
	AttachStderr    bool
	PortSpecs       []string
	ExposedPorts    map[Port]struct{}
	OnBuild         []string
	Tty             bool
	OpenStdin       bool
	StdinOnce       bool
	Env             []string
	Cmd             []string
	Dns             []string // For Docker API v1.9 and below only
	Image           string
	Volumes         map[string]struct{}
	VolumesFrom     string
	WorkingDir      string
	Entrypoint      []string
	NetworkDisabled bool
}

type ContainerConfig

type ContainerConfig struct {
	Hostname        string
	Domainname      string
	Entrypoint      []string
	User            string
	Memory          int64
	MemorySwap      int64
	CpuShares       int64
	AttachStdin     bool
	AttachStdout    bool
	AttachStderr    bool
	PortSpecs       []string
	Tty             bool
	OpenStdin       bool
	StdinOnce       bool
	NetworkDisabled bool
	OnBuild         []string
	Env             []string
	Cmd             []string
	Dns             []string
	Image           string
	Volumes         map[string]struct{}
	VolumesFrom     string
}

type LayerConfig

type LayerConfig struct {
	Id                string           `json:"id"`
	Parent            string           `json:"parent,omitempty"`
	Comment           string           `json:"comment"`
	Created           time.Time        `json:"created"`
	V1ContainerConfig *ContainerConfig `json:"ContainerConfig,omitempty"`  // Docker 1.0.0, 1.0.1
	V2ContainerConfig *ContainerConfig `json:"container_config,omitempty"` // All other versions
	Container         string           `json:"container"`
	Config            *Config          `json:"config,omitempty"`
	DockerVersion     string           `json:"docker_version"`
	Architecture      string           `json:"architecture"`
}

func (*LayerConfig) ContainerConfig

func (l *LayerConfig) ContainerConfig() *ContainerConfig

type Port

type Port string

func (Port) Port

func (p Port) Port() string

Port returns the number of the port.

func (Port) Proto

func (p Port) Proto() string

Proto returns the name of the protocol.

type TagInfo

type TagInfo map[string]string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL