Compose: Ports with letter gives "ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?"

Created on 18 Nov 2015  路  9Comments  路  Source: docker/compose

% cat ports-fail.yml 
foo:
    image: busybox
    ports:
        - '8765:80'
    command: sh -c "exit 0"

bar:
    image: busybox
    ports:
        - '8765a:80'
    command: sh -c "exit 0"

% docker-compose -f ports-fail.yml up
Creating tmp_foo_1
Creating tmp_bar_1
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.

% docker run --rm -p '8765a:80' busybox sh -c 'exit 0'
docker: Invalid hostPort: 8765a.
See 'docker run --help'.

% docker-compose --version
docker-compose version: 1.5.0

% docker --version
Docker version 1.7.1, build 786b29d

Anything else needed to debug?

areconfig kinbug

Most helpful comment

If you are on ubuntu-like distro then just sudo it.

All 9 comments

At the very least we can better validate the format of ports.

I'm not sure why it can't connect to the daemon. Does docker crash? Could you try reproducing with the latest version of docker ?

I just reproduced with the latest docker. Notice that this is plain Copy'n'Paste, so the docker daemon didn't crash ...

% cat ports-fail.yml 
foo:
    image: busybox
    ports:
        - '8765:80'
    command: sh -c "exit 0"

bar:
    image: busybox
    ports:
        - '8765a:80'
    command: sh -c "exit 0"

% docker-compose -f ports-fail.yml up
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.

% docker run --rm -p '8765a:80' busybox sh -c 'exit 0'
docker: Invalid hostPort: 8765a.
See 'docker run --help'.

% docker-compose --version
docker-compose version: 1.5.0

% docker --version
Docker version 1.9.0, build 76d6bc9

I have the same issue on two different machines. Both running CentOS Linux release 7.1.1503.

Moreover - default installation of docker-compose by pip on this CentOS version fail. Actually installation is fine but when You try start docker-compose You got error and You need to execute "pip install docker-compose --upgrade". Then docker-compose itself works but produces error as mentioned here. Setting DOCKER_HOST didn't help.

This is almost certainly caused by the daemon crashing when it fails to parse the port. We've had this before and I believed it was fixed on the daemon side - see https://github.com/docker/docker/pull/14682.

@ct-clearhaus: After upgrading to 1.9.0, did you restart the daemon? What's the output of docker version? (docker --version only reports the client version)

@duglin, @calavera: what Docker release did that fix go out in?

@aanand I have this issue still in 1.9.1:

Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.2
Git commit: a34a1d5
Built: Fri Nov 20 13:25:01 UTC 2015
OS/Arch: linux/amd64

@aanand I see it in the v1.8.0 git logs.

Using v1.9.0 I see the error being caught by the CLI. If I use the REST APIs, I see the daemon returning the error. Before the fix I believe the daemon would crash and result in the error being shown, but now I see it just returning the error w/o crashing.

Hi @aanand,

After upgrading to 1.9.0, did you restart the daemon?

I was hit by https://github.com/docker/docker/issues/17688 so the restart came "automatically" :wink:

What's the output of docker version? (docker --version only reports the client version)

Right, I obviously didn't put enough thought into that. Now, when I try reproducing:

% docker-compose -f ports-fail.yml up
Starting tmp_foo_1
Starting tmp_bar_1
ERROR: Invalid port specification: "8765a"
% docker version
Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:43:42 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   76d6bc9
 Built:        Tue Nov  3 17:43:42 UTC 2015
 OS/Arch:      linux/amd64

It might very well be the case that docker daemon was actually not running when I produced the output in https://github.com/docker/compose/issues/2414#issuecomment-157758721.

So, basically, I guess you're spot on:

This is almost certainly caused by the daemon crashing when it fails to parse the port.

And my "so the docker daemon didn't crash" is most likely wrong, because the config failure wasn't just catched in the CLI from 1.9 but probably earlier, so the

% docker run --rm -p '8765a:80' busybox sh -c 'exit 0'
docker: Invalid hostPort: 8765a.
See 'docker run --help'.

is probably due to the CLI, not the daemon.

Thus, closing.

If you are on ubuntu-like distro then just sudo it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maltefiala picture maltefiala  路  3Comments

dazorni picture dazorni  路  3Comments

HackerWilson picture HackerWilson  路  3Comments

29e7e280-0d1c-4bba-98fe-f7cd3ca7500a picture 29e7e280-0d1c-4bba-98fe-f7cd3ca7500a  路  3Comments

darkrasid picture darkrasid  路  3Comments