Merge pull request #3853 from dgageot/faster-export

Faster image export
This commit is contained in:
Avi Deitcher 2022-10-12 14:34:51 +03:00 committed by GitHub
commit 61a07e26cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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
// 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)
cli, err := Client()
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
config := &container.Config{
Cmd: []string{"/dev/null"},
Image: image,
Cmd: []string{"/dev/null"},
Image: image,
NetworkDisabled: !withNetwork,
}
respBody, err := cli.ContainerCreate(context.Background(), config, nil, nil, nil, "")
if err != nil {
return "", err

View File

@ -58,7 +58,7 @@ func (d ImageSource) Config() (imagespec.ImageConfig, error) {
// TarReader return an io.ReadCloser to read the filesystem contents of the image.
func (d ImageSource) TarReader() (io.ReadCloser, error) {
container, err := Create(d.ref.String())
container, err := Create(d.ref.String(), false)
if err != nil {
return nil, fmt.Errorf("Failed to create docker image %s: %v", d.ref, err)
}