Skip to content

Commit c127d96

Browse files
author
Doug Davis
committed
Add the mediaType to the error
Without this fix the error the client might see is: target is unknown which wasn't helpful to me when I saw this today. With this fix I now see: MediaType is unknown: 'text/html' which helped me track down the issue to the registry I was talking to. Signed-off-by: Doug Davis <[email protected]>
1 parent cdc79c5 commit c127d96

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

cli/command/image/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func runPull(dockerCli *command.DockerCli, opts pullOptions) error {
7676
err = imagePullPrivileged(ctx, dockerCli, authConfig, reference.FamiliarString(distributionRef), requestPrivilege, opts.all)
7777
}
7878
if err != nil {
79-
if strings.Contains(err.Error(), "target is plugin") {
79+
if strings.Contains(err.Error(), "when fetching 'plugin'") {
8080
return errors.New(err.Error() + " - Use `docker plugin install`")
8181
}
8282
return err

cli/command/plugin/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func runInstall(dockerCli *command.DockerCli, opts pluginOptions) error {
152152

153153
responseBody, err := dockerCli.Client().PluginInstall(ctx, alias, options)
154154
if err != nil {
155-
if strings.Contains(err.Error(), "target is image") {
155+
if strings.Contains(err.Error(), "(image) when fetching") {
156156
return errors.New(err.Error() + " - Use `docker image pull`")
157157
}
158158
return err

distribution/pull_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat
363363
if configClass == "" {
364364
configClass = "unknown"
365365
}
366-
return false, fmt.Errorf("target is %s", configClass)
366+
return false, fmt.Errorf("Encountered remote %q(%s) when fetching", m.Manifest.Config.MediaType, configClass)
367367
}
368368
}
369369

integration-cli/docker_cli_plugins_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (s *DockerRegistrySuite) TestPluginInstallImage(c *check.C) {
181181

182182
out, _, err := dockerCmdWithError("plugin", "install", repoName)
183183
c.Assert(err, checker.NotNil)
184-
c.Assert(out, checker.Contains, "target is image")
184+
c.Assert(out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
185185
}
186186

187187
func (s *DockerSuite) TestPluginEnableDisableNegative(c *check.C) {

0 commit comments

Comments
 (0)