Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: better error message for 'docker create network' and other similar incorrect patterns #1986

Open
bartolone opened this issue Jul 5, 2019 · 2 comments

Comments

@bartolone
Copy link

Description

When trying the (incorrect) command docker create network ... the user receives a potentially unhelpful error message: Unable to find image 'network:latest' locally (this also applies to config, container, plugin, secret, service, and volume in addition to network). This error message is unintuitive if the user is attempting to create a network and does not redirect them to the correct syntax.

This incorrect pattern seems to be relatively common (see the following examples):
*jupyterhub/jupyterhub#2632
*nginx-proxy/nginx-proxy#502 (comment)
*https://github.com/fluencelabs/fluence/blob/master/bootstrap/private_ethereum.md

I propose a new error message to redirect users to the correct pattern as it is much more likely their intent to create a network than to create a container named 'network'. This would likely also necessitate precluding users from naming their containers any one of config, container, network, plugin, secret, service, or volume, but use of those names should probably be discouraged anyway.

I would be happy to take a stab at a PR, but I am not familiar enough with the codebase to be sure of all of the files that would need updating. If someone is willing to help me identify those, I will go ahead and take a shot at it. Also happy to defer if anyone else wants to tackle this, but wanted to get feedback first on if this idea would be supported.

Steps to reproduce the issue:

  1. Type docker create network or substitute any of config, container, plugin, secret, service, and volume in place of network

Describe the results you received:
Unable to find image 'network:latest' locally
Error response from daemon: pull access denied for network, repository does not exist or may require 'docker login'

Describe the results you expected:
Error: cannot create a container named 'network'
If you were trying to create a network, see 'docker network create --help'

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 4
 Running: 4
 Paused: 0
 Stopped: 0
Images: 68
Server Version: 18.09.2
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 6
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: CULL:2WW2:SCNC:EGFF:SS5X:LCJK:NRKW:LFJW:RBUE:JH4T:X3XT:N5E3
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 63
 Goroutines: 101
 System Time: 2019-07-05T19:45:43.012106973Z
 EventsListeners: 3
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
@cpuguy83
Copy link
Collaborator

cpuguy83 commented Jul 5, 2019

Makes sense, though error message maybe could be error while creating container: <error>

@bartolone
Copy link
Author

I like that, since it makes explicit that what the user typed is the container creation function, when they meant to create a network (or something else).

bartolone added a commit to bartolone/cli that referenced this issue Jul 7, 2019
…network instead of docker network create (or config, container, plugin, secret, service, or volume). Addresses issue docker#1986

Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>
bartolone added a commit to bartolone/cli that referenced this issue Jul 7, 2019
…y cpuguy83 in the discussion of issue docker#1986

Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>
bartolone added a commit to bartolone/cli that referenced this issue Jul 7, 2019
Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>

Added additional error message context when user types docker create network instead of docker network create (or config, container, plugin, secret, service, or volume). Addresses issue docker#1986

Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>

Added additional context to the original error message as suggested by cpuguy83 in the discussion of issue docker#1986

Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>
bartolone added a commit to bartolone/cli that referenced this issue Jul 7, 2019
Added additional error message context when user types docker create network instead of docker network create (or config, container, plugin, secret, service, or volume). Addresses issue docker#1986

Added additional context to the original error message as suggested by cpuguy83 in the discussion of issue docker#1986

fixed namedReference to string comparison

fixing another typo

fixing line length to pass linter test

another update to pass the linter

Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>
bartolone added a commit to bartolone/cli that referenced this issue Jul 9, 2019
…tead of docker network create (or other similar mistakes)

When a user is attempting to create a network and mistakenly types docker create network instead of the correct docker network create,
this adds additional error message context to point the user to the correct command. This applies to config, container, plugin,
secret, service, and volume in addition to network. Also updated the generic error message for docker create to begin with "Error while
creating container" to make clear that the create command defaults to container create. Also fixed a comment typo in create.go and updated
the e2e test golden file containing expected error messages for jenkins CI testing to now look for the updated error message.

Resolves issue docker#1986

Signed-off-by: Jake Bartolone <jakebartolone@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants