Fix image pull logic
This commit is contained in:
10
docker.go
10
docker.go
@ -98,19 +98,21 @@ func (lc LabeledContainer) UpdateTo(cli *client.Client, tag Tag) error {
|
|||||||
fmt.Printf("Pulling image \"%s\"\n", canonicalImage)
|
fmt.Printf("Pulling image \"%s\"\n", canonicalImage)
|
||||||
|
|
||||||
//containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
|
//containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
|
||||||
rc, err := cli.ImagePull(ctx, canonicalImage, types.ImagePullOptions{})
|
imageReader, err := cli.ImagePull(ctx, canonicalImage, types.ImagePullOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: does it still pull the image if i just close the reader?
|
defer imageReader.Close()
|
||||||
err = rc.Close()
|
|
||||||
|
loadResponse, err := cli.ImageLoad(ctx, imageReader, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer loadResponse.Body.Close()
|
||||||
|
|
||||||
fmt.Printf("Stopping container %s\n", lc.Container.ID)
|
fmt.Printf("Stopping container %s\n", lc.Container.ID)
|
||||||
// TODO: hopefully this is blocking
|
|
||||||
err = cli.ContainerStop(ctx, lc.Container.ID, nil)
|
err = cli.ContainerStop(ctx, lc.Container.ID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user