gogetdockerimage

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 8 Imported by: 0

README

Go Report Card Go Go Doc Release Gitpod Ready-to-Code

About

Go-getdockerimage is a utility tool to download images from docker hub and export them. Exporting images is useful, if you have a server without access to docker hub.

No magick involved. This tool is just a convenient wrapper for regular docker cli.

Use case

  • Export image on a machine with access to docker hub
  • Copy image to your server
  • Load image with docker load --input MyImage

Requirements

Docker is installed on your machine.

Quickstart

Checkout the project and run make (given that go build chain is installed). Hint: You can simply click on the Gitpod link above and compile it online without setting up a tool chain.

make all

Installation

Simply grep the latest available binary from the release page and put it somewhere in your path.

If go is installed and $GOPATH/bin is in your path, you can download and install the tool directly by using go install.

Download tool:

# get latest version
go install github.com/EricNeid/go-getdockerimage/cmd/getdockerimage@latest
# or get specific version
go install github.com/EricNeid/go-getdockerimage/cmd/getdockerimage@v0.6.0

Usage

Download image:

getdockerimage.exe foo/image:2.0.0
=> foo_image_2.0.0.img

Download image from different registry:

getdockerimage.exe myregistry:1234/foo/image:2.0.0
=> foo_image_2.0.0.img

Download image(s) from dockerfile or docker-compose.yml

getdockerimage.exe ./my-docker-project/Dockerfile
=> foo_image_2.0.0.img

Download all required images for project, by checking dockerfile and docker-compose.yml:

getdockerimage.exe ./my-docker-project
=> foo_image_2.0.0.img
=> bar_image_2.0.0.img

Store images to folder:

getdockerimage.exe -dir=out foo/image:2.0.0
=> out/foo_image_2.0.0.img

Question or comments

Please feel free to open a new issue: https://github.com/EricNeid/go-getdockerimage/issues

Documentation

Overview

Package gogetdockerimage contains functions to download and save docker images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadImage

func DownloadImage(imageName string) error

DownloadImage download docker image by name.

func GetCustomRegistry added in v0.6.0

func GetCustomRegistry(image string) (string, error)

GetCustomRegistry return the name of custom registry, if present

func GetImagesFromDockerCompose

func GetImagesFromDockerCompose(dockerfilePath string) ([]string, error)

GetImagesFromDockerCompose returns all images found in given docker-compose file. It search for occurrences of "image: <imageName>" or "image: "<imageName>"" Search is performed case insensitive.

func GetImagesFromDockerfile

func GetImagesFromDockerfile(dockerfilePath string) ([]string, error)

GetImagesFromDockerfile returns all images found in given Dockerfile. It search for occurrences of "FROM imageName" or "FROM imageName AS alias" Search is performed case insensitive. Declaration of scratch is ignored.

func GetOutputName

func GetOutputName(image string) (string, error)

GetOutputName returns name of generated file from image name foo -> foo.docker.img foo/bar -> foo_bar.docker.img foo/bar:42 -> foo_bar_42.docker.img

func RemoveDir

func RemoveDir(dir string) error

RemoveDir deletes directory and all files in it.

func SaveImage

func SaveImage(imageName, outDir, outName string) error

SaveImage write docker image to file system.

Types

This section is empty.

Directories

Path Synopsis
cmd
getdockerimage
SPDX-FileCopyrightText: 2021 Eric Neidhardt SPDX-License-Identifier: MIT
SPDX-FileCopyrightText: 2021 Eric Neidhardt SPDX-License-Identifier: MIT
internal
verify
Package verify provides utility functions for tests.
Package verify provides utility functions for tests.

Jump to

Keyboard shortcuts

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