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

Very misleading error messaging from typo in yaml file. #2816

Closed
endophage opened this issue Feb 3, 2016 · 9 comments
Closed

Very misleading error messaging from typo in yaml file. #2816

endophage opened this issue Feb 3, 2016 · 9 comments

Comments

@endophage
Copy link

So I had an errant - in my compose yaml file, and it manifested itself during docker-compose build as the following error:

Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

The yml file was bad in the below format (the service name was prefixed with the -):

-test:
    build: .
    dockerfile: Dockerfile

The error docker is returning (dug it out of journalctl) is:

Feb 03 15:51:05 endophage docker[593]: time="2016-02-03T15:51:05.252721921-08:00" level=info msg="POST /v1.19/build?pull=False&nocache=False&q=False&t=david_-test&forcerm=False&rm=True&dockerfile=server.Dockerfile"
Feb 03 15:51:05 endophage docker[593]: time="2016-02-03T15:51:05.252859421-08:00" level=error msg="Handler for POST /v1.19/build returned error: repository name component must match \"[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*\""
Feb 03 15:51:05 endophage docker[593]: time="2016-02-03T15:51:05.252878753-08:00" level=error msg="HTTP Error" err="repository name component must match \"[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*\"" statusCode=500

My error in the yaml file is obvious now I've seen it but the error message is very unintuitive and I assume this isn't the only case in which docker returns a reasonable (if technical) error message and compose returns something more obscure.

FYI, when trying to build a similarly badly named thing on docker itself, it returns the expected error:

15:52 $ docker build -t -test .
[sudo] password for david: 
repository name component must match "[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*"
@dnephin
Copy link

dnephin commented Feb 3, 2016

That's really strange, our config validation should have noticed this and provided a good error message. What version of compose are you running (docker-compose version)?

The output of docker-compose --verbose build (with the bad config) would also be helpful.

@dnephin
Copy link

dnephin commented Feb 4, 2016

Ah, I see the problem from the docker log. I assumed it treated -test as a list, but it's reading it as a string with a leading dash.

@dnephin dnephin added this to the 1.6.1 milestone Feb 4, 2016
@dnephin
Copy link

dnephin commented Feb 4, 2016

@endophage we might be able to work around this from compose, but I think this is actually a bug in docker engine.

An invalid input should be a 400 status code, not a 500.

@endophage
Copy link
Author

@dnephin yeah, I believe yaml requires a space between the dash and the following content to treat it as a list.

I'm running 1.4.0, I guess I missed the last update or two. Updated to 1.6.0 RC2 and the error is now:

ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.

You're right, this should be a 400, but even a 500 indicates you contacted the server (daemon) so an error message indicating compose couldn't connect seems like something that should be changed on the compose side.

@dnephin
Copy link

dnephin commented Feb 4, 2016

I think docker-py translates everything into an APIError. It may be that APIError needs to be split up into a few different errors so we can differentiate these failures. I know we have a couple related issues about reporting this same error message for proxy errors, and ssl errors as well.

@endophage
Copy link
Author

That makes sense. Should this be closed and the same issue filed over on the docker-py repo? Or will there be some integration work here too?

@dnephin
Copy link

dnephin commented Feb 4, 2016

We'll often keep the compose issue open to track updating the version of docker-py, so I think it's fine to keep this open.

@dnephin dnephin self-assigned this Feb 10, 2016
@dnephin
Copy link

dnephin commented Feb 10, 2016

@endophage I took another look into these errors in an attempt to fix the behaviour.

I once again believe this is an engine bug. I tried this with docker-py:

client.build('.', '-test')
ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer')) 

It's not even a 500 error, it a TCP connection error, so I think the error we're responding with is correct.

I also tried the docker build example you gave with docker 1.10, but it's not even sending it to the API, it's being caught during command line flag parsing with:

$ docker build -t -test .
invalid value "-test" for flag -t: Error parsing reference: "-test" is not a valid repository/tag

There's not much we can do here until docker engine responds with a valid HTTP response code. I believe even with a 500 code we would echo the error message and exit properly.

I don't think it's correct to duplicate the tag validation in the client.

@shin-
Copy link

shin- commented Sep 13, 2016

Looks like this is working properly now:

$ cat docker-compose.yml 
version: '2'
services:
  -service:
    build:
      context: .
$ docker-compose up
Building -service
ERROR: Error parsing reference: "repro2816_-service" is not a valid repository/tag

@shin- shin- closed this as completed Sep 13, 2016
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

3 participants