mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
Merge pull request #3853 from dgageot/faster-export
Faster image export
This commit is contained in:
commit
61a07e26cf
@ -78,7 +78,7 @@ func InspectImage(cli *client.Client, ref *reference.Spec) (dockertypes.ImageIns
|
|||||||
|
|
||||||
// Create create a container from the given image in docker, returning the full hash ID
|
// Create create a container from the given image in docker, returning the full hash ID
|
||||||
// of the created container. Does not start the container.
|
// of the created container. Does not start the container.
|
||||||
func Create(image string) (string, error) {
|
func Create(image string, withNetwork bool) (string, error) {
|
||||||
log.Debugf("docker create: %s", image)
|
log.Debugf("docker create: %s", image)
|
||||||
cli, err := Client()
|
cli, err := Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -86,9 +86,11 @@ func Create(image string) (string, error) {
|
|||||||
}
|
}
|
||||||
// we do not ever run the container, so /dev/null is used as command
|
// we do not ever run the container, so /dev/null is used as command
|
||||||
config := &container.Config{
|
config := &container.Config{
|
||||||
Cmd: []string{"/dev/null"},
|
Cmd: []string{"/dev/null"},
|
||||||
Image: image,
|
Image: image,
|
||||||
|
NetworkDisabled: !withNetwork,
|
||||||
}
|
}
|
||||||
|
|
||||||
respBody, err := cli.ContainerCreate(context.Background(), config, nil, nil, nil, "")
|
respBody, err := cli.ContainerCreate(context.Background(), config, nil, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -58,7 +58,7 @@ func (d ImageSource) Config() (imagespec.ImageConfig, error) {
|
|||||||
|
|
||||||
// TarReader return an io.ReadCloser to read the filesystem contents of the image.
|
// TarReader return an io.ReadCloser to read the filesystem contents of the image.
|
||||||
func (d ImageSource) TarReader() (io.ReadCloser, error) {
|
func (d ImageSource) TarReader() (io.ReadCloser, error) {
|
||||||
container, err := Create(d.ref.String())
|
container, err := Create(d.ref.String(), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to create docker image %s: %v", d.ref, err)
|
return nil, fmt.Errorf("Failed to create docker image %s: %v", d.ref, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user