Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 26477e2

Browse files
authored
Merge pull request #221 from carmark/inspect_image
check image before pull image in cron and service
2 parents 5b90053 + 97ae0cf commit 26477e2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

api/client/cron.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ func (cli *DockerCli) CmdCronCreate(args ...string) error {
103103
entrypoint = strslice.StrSlice{*flEntrypoint}
104104
}
105105

106-
if err := cli.pullImage(context.Background(), image); err != nil {
107-
return err
106+
if _, _, err = cli.client.ImageInspectWithRaw(context.Background(), image, false); err != nil {
107+
if err := cli.pullImage(context.Background(), image); err != nil {
108+
return err
109+
}
108110
}
109111

110112
// collect all the environment variables for the container

api/client/service.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ func (cli *DockerCli) CmdServiceCreate(args ...string) error {
9090
image = cmd.Arg(0)
9191
)
9292

93-
if err := cli.pullImage(context.Background(), image); err != nil {
94-
return err
93+
if _, _, err = cli.client.ImageInspectWithRaw(context.Background(), image, false); err != nil {
94+
if err := cli.pullImage(context.Background(), image); err != nil {
95+
return err
96+
}
9597
}
9698

9799
if len(parsedArgs) > 1 {

0 commit comments

Comments
 (0)