Skip to content

Commit

Permalink
container: properly handle 404s on container creation
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Jan 16, 2019
1 parent d574e25 commit 07f7952
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func (c *Client) CreateContainer(opts CreateContainerOptions) (*Container, error
)

if e, ok := err.(*Error); ok {
if e.Status == http.StatusNotFound {
if e.Status == http.StatusNotFound && strings.Contains(e.Message, "No such image") {
return nil, ErrNoSuchImage
}
if e.Status == http.StatusConflict {
Expand Down
2 changes: 1 addition & 1 deletion container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ func TestCreateContainer(t *testing.T) {

func TestCreateContainerImageNotFound(t *testing.T) {
t.Parallel()
client := newTestClient(&FakeRoundTripper{message: "No such image", status: http.StatusNotFound})
client := newTestClient(&FakeRoundTripper{message: "No such image: whatever", status: http.StatusNotFound})
config := Config{AttachStdout: true, AttachStdin: true}
container, err := client.CreateContainer(CreateContainerOptions{Config: &config})
if container != nil {
Expand Down

0 comments on commit 07f7952

Please sign in to comment.