README
¶
undocker
Go library and command line tool for decomposing docker images.
Command Use
Usage
NAME:
undocker - Decompose docker images.
USAGE:
undocker [global options] command [command options] [arguments...]
VERSION:
0.1.3
COMMANDS:
extract, e Extract to rootfs.
show, s Show image informations
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--registry-url value, -r value docker registry url [$REGISTRY_URL]
--registry-user value, -u value docker registry login username [$REGISTRY_USER]
--registry-pass value, -p value docker registry login password [$REGISTRY_PASS]
--help, -h show help
--version, -v print the version
Installation
homebrew tap:
$ brew install tokibi/tap/undocker
manually:
Download binany from releases page
go get:
$ go get github.com/tokibi/undocker/cmd/undocker
Extract
Extract from local images.
$ undocker extract busybox:latest ./image
$ ls ./image
bin/ dev/ etc/ home/ root/ tmp/ usr/ var/
Extract directly from docker registry.
$ export REGISTRY_USER=xxx # optional
$ export REGISTRY_PASS=xxx # optional
$ undocker -r "https://registry-1.docker.io/" extract busybox:latest ./image
Config
Show image config.
$ undocker show config busybox:latest | jq
{
"architecture": "amd64",
"config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"sh"
],
...
Library Use
Extract
Extract from local images.
func main() {
dst := "./image"
api, err := undocker.NewDockerAPI()
if err != nil {
log.Fatal(err)
}
api.Image("busybox", "latest").Extract(dst, false)
}
Extract directly from docker registry.
func main() {
url := "https://registry-1.docker.io/"
username := ""
password := ""
dst := "./image"
registry, err := undocker.NewRegistry(url, username, password)
if err != nil {
log.Fatal(err)
}
registry.Image("busybox", "latest").Extract(dst, false)
}
Config
func main() {
api, _ := undocker.NewDockerAPI()
config, err := api.Image("busybox", "latest").Config()
if err != nil {
return err
}
fmt.Println(config.architecture)
}
Documentation
¶
Index ¶
- type Config
- type ContainerConfig
- type DockerAPI
- func (api DockerAPI) CleanUp() error
- func (api DockerAPI) Config(repository, tag string) ([]byte, error)
- func (api DockerAPI) Exists(repository, tag string) bool
- func (api DockerAPI) Find(repository, tag string) (string, error)
- func (api DockerAPI) Image(repository, tag string) Image
- func (api DockerAPI) ImageBlob(repository, tag string) (*ImageBlob, error)
- func (api DockerAPI) LayerBlobs(repository, tag string) ([]io.Reader, error)
- type History
- type Image
- type ImageBlob
- type ImageConfig
- type Manifest
- type Options
- type Registry
- func (r Registry) CleanUp() error
- func (r Registry) Config(repository, tag string) ([]byte, error)
- func (r Registry) Exists(repository, tag string) bool
- func (r Registry) ExtractedBlob(repository string, digest digest.Digest) (io.Reader, error)
- func (r Registry) Find(repository, tag string) error
- func (r Registry) Image(repository, tag string) Image
- func (r Registry) LayerBlobs(repository, tag string) ([]io.Reader, error)
- func (r Registry) Layers(repository, tag string) ([]distribution.Descriptor, error)
- func (r Registry) Manifest(repository, tag string) (*schema2.DeserializedManifest, error)
- type Rootfs
- type Source
- type Undocker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Hostname string `json:"Hostname"` Domainname string `json:"Domainname"` User string `json:"User"` AttachStdin bool `json:"AttachStdin"` AttachStdout bool `json:"AttachStdout"` AttachStderr bool `json:"AttachStderr"` Tty bool `json:"Tty"` OpenStdin bool `json:"OpenStdin"` StdinOnce bool `json:"StdinOnce"` Env []string `json:"Env"` Cmd []string `json:"Cmd"` ArgsEscaped bool `json:"ArgsEscaped"` Image string `json:"Image"` Volumes []string `json:"Volumes"` WorkingDir string `json:"WorkingDir"` Entrypoint []string `json:"Entrypoint"` OnBuild []string `json:"OnBuild"` Labels map[string]string `json:"Labels"` }
type ContainerConfig ¶
type ContainerConfig struct { Hostname string `json:"Hostname"` Domainname string `json:"Domainname"` User string `json:"User"` AttachStdin bool `json:"AttachStdin"` AttachStdout bool `json:"AttachStdout"` AttachStderr bool `json:"AttachStderr"` Tty bool `json:"Tty"` OpenStdin bool `json:"OpenStdin"` StdinOnce bool `json:"StdinOnce"` Env []string `json:"Env"` Cmd []string `json:"Cmd"` ArgsEscaped bool `json:"ArgsEscaped"` Image string `json:"Image"` Volumes []string `json:"Volumes"` WorkingDir string `json:"WorkingDir"` Entrypoint []string `json:"Entrypoint"` OnBuild []string `json:"OnBuild"` Labels map[string]string `json:"Labels"` }
type DockerAPI ¶
type DockerAPI struct {
// contains filtered or unexported fields
}
func NewDockerAPI ¶
type Image ¶
func (Image) Config ¶
func (i Image) Config() (*ImageConfig, error)
func (Image) Extract ¶ added in v0.1.3
Extract extracts docker image as rootfs to the specified directory
func (Image) LayerBlobs ¶
LayerBlobs return the layers of the image in order from the lower
type ImageBlob ¶
type ImageBlob struct {
Blob io.ReadCloser
}
type ImageConfig ¶
type ImageConfig struct { Architecture string `json:"architecture"` Config Config `json:"config"` Container string `json:"container"` ContainerConfig ContainerConfig `json:"container_config"` Created time.Time `json:"created"` DockerVersion string `json:"docker_version"` History History `json:"history"` OS string `json:"os"` Rootfs Rootfs `json:"rootfs"` }
type Registry ¶
type Registry struct { URL *url.URL Username string Password string // contains filtered or unexported fields }
func NewRegistry ¶
func (Registry) ExtractedBlob ¶
func (Registry) LayerBlobs ¶
func (Registry) Layers ¶
func (r Registry) Layers(repository, tag string) ([]distribution.Descriptor, error)
Click to show internal directories.
Click to hide internal directories.