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

Cannot start services when ports are mentioned #4729

Closed
drgroot opened this issue Apr 12, 2017 · 17 comments
Closed

Cannot start services when ports are mentioned #4729

drgroot opened this issue Apr 12, 2017 · 17 comments
Labels
Milestone

Comments

@drgroot
Copy link

drgroot commented Apr 12, 2017

For some reason I cannot bind the port correctly. When I remove the port, it works. If i change the port to any other number, it still does not work

version: '3'
services:
  rtorrent:
    container_name: rtorrent
    image: yusufali/rtorrent
    privileged: true
  web_nginx:
    container_name: web_nginx
    image: marvambass/nginx-ssl-secure
    links:
      - rtorrent:rtorrent
    ports:
      - "8800:80"

However, run I run docker-com up -d, this does not work

Creating network "docker_default" with the default driver
Creating rtorrent
Creating web_nginx

ERROR: for web_nginx  Cannot create container for service web_nginx: invalid port specification: "None"
ERROR: Encountered errors while bringing up the project.

Useful info:

# docker-compose --version
docker-compose version 1.12.0, build b31ff33
# docker --version
Docker version 17.04.0-ce, build 4845c56
# uname -a
Linux gsad 4.4.30-mod-std-ipv6-64 #9 SMP Tue Nov 1 17:58:26 CET 2016 x86_64 GNU/Linux
@drgroot drgroot changed the title Docker compose is just not doing anything correct Cannot start services when ports are mentioned Apr 12, 2017
@shin-
Copy link

shin- commented Apr 12, 2017

That same setup works fine for me. Is that your entire docker-compose.yml file? Do you have a docker-compose.override.yml?

@drgroot
Copy link
Author

drgroot commented Apr 12, 2017

No i do not.

@shin-
Copy link

shin- commented Apr 12, 2017

Have you tried to isolate the issue into a smaller example? Do you still see the same bug with a simpler Compose file, e.g.

version: '3'
services:
  foo:
    image: alpine
    ports:
      - "8800:80"

Make sure it's in a separate, empty folder.

@drgroot
Copy link
Author

drgroot commented Apr 13, 2017

same issue. done in a separate folder.

Its really weird cuz it works fine when I manually perform the operation using the 'docker create -p ...' command

@shin-
Copy link

shin- commented Apr 14, 2017

Hmm, that's interesting. Did you install Compose using pip or did you download the binary? If you're using pip, what's your python --version?
Also, could you run the following commands and share the output:

  • docker-compose config
  • docker-compose --verbose up -d

@drgroot
Copy link
Author

drgroot commented Apr 15, 2017

pip3 install --upgrade docker-compose

$ python3 --version
  Python 3.4.2

For the docker-compose config:

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/main.py", line 67, in main
    command()
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/main.py", line 111, in perform_command
    handler(command, options, command_options)
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/main.py", line 306, in config
    print(serialize_config(compose_config, image_digests))
  File "/usr/local/lib/python3.4/dist-packages/compose/config/serialize.py", line 62, in serialize_config
    width=80)
  File "/usr/local/lib/python3.4/dist-packages/yaml/__init__.py", line 216, in safe_dump
    return dump_all([data], stream, Dumper=SafeDumper, **kwds)
  File "/usr/local/lib/python3.4/dist-packages/yaml/__init__.py", line 188, in dump_all
    dumper.represent(data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 26, in represent
    node = self.represent_data(data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 47, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 205, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 116, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 47, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 205, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 116, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 47, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 205, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 116, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 57, in represent_data
    node = self.yaml_representers[None](self, data)
  File "/usr/local/lib/python3.4/dist-packages/yaml/representer.py", line 229, in represent_undefined
    raise RepresenterError("cannot represent an object: %s" % data)
yaml.representer.RepresenterError: cannot represent an object: <map object at 0x77fd26e406a0>

Docker compose verbose,


root@bilbo:/home/media# docker-compose --verbose up -d
compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.auth.find_config_file: Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
docker.auth.find_config_file: No config file found
compose.cli.command.get_client: docker-compose version 1.12.0, build b31ff33
docker-py version: 2.2.1
CPython version: 3.4.2
OpenSSL version: OpenSSL 1.0.1t  3 May 2016
compose.cli.command.get_client: Docker base_url: http+docker://localunixsocket
compose.cli.command.get_client: Docker version: GitCommit=4845c56, MinAPIVersion=1.12, Arch=amd64, BuildTime=2017-04-03T17:45:49.040323876+00:00, KernelVersion=3.14.32-xxxx-grs-ipv6-64, Version=17.04.0-ce, ApiVersion=1.28, GoVersion=go1.7.5, Os=linux
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
compose.cli.verbose_proxy.proxy_callable: docker info -> {'Architecture': 'x86_64',
 'BridgeNfIp6tables': True,
 'BridgeNfIptables': True,
 'CPUSet': True,
 'CPUShares': True,
 'CgroupDriver': 'cgroupfs',
 'ClusterAdvertise': '',
 'ClusterStore': '',
 'ContainerdCommit': {'Expected': '422e31ce907fd9c3833a38d7b8fdd023e5a76e73',
                      'ID': '422e31ce907fd9c3833a38d7b8fdd023e5a76e73'},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('media_default')
compose.network.ensure: Creating network "media_default" with the default driver
compose.cli.verbose_proxy.proxy_callable: docker create_network <- (driver=None, attachable=True, options=None, ipam=None, enable_ipv6=False, name='media_default', labels={'com.docker.compose.project': 'media', 'com.docker.compose.network': 'default'}, internal=False)
compose.cli.verbose_proxy.proxy_callable: docker create_network -> {'Id': '6a361460c517da0f8c8742f77ce9e76a474d8e5dbf24404b47cbea02ab138a99',
 'Warning': ''}
compose.cli.verbose_proxy.proxy_callable: docker containers <- (filters={'label': ['com.docker.compose.project=media', 'com.docker.compose.oneoff=False']}, all=False)
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (filters={'label': ['com.docker.compose.project=media', 'com.docker.compose.service=foo', 'com.docker.compose.oneoff=False']}, all=True)
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('alpine')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (filters={'label': ['com.docker.compose.project=media', 'com.docker.compose.service=foo', 'com.docker.compose.oneoff=False']}, all=True)
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.parallel.feed_queue: Pending: {<Service: foo>}
compose.parallel.feed_queue: Starting producer thread for <Service: foo>
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('alpine')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (filters={'label': ['com.docker.compose.project=media', 'com.docker.compose.service=foo', 'com.docker.compose.oneoff=False']}, all=True)
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('alpine')
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': None,
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
...
compose.service.build_container_labels: Added config hash: df12277d2b94980b1245953ec768c3916e94b9228becf2a5615e95a786b82771
compose.cli.verbose_proxy.proxy_callable: docker create_host_config <- (cpu_quota=None, cap_add=None, port_bindings={'None/tcp': [None]}, cap_drop=None, devices=None, cgroup_parent=None, dns_search=None, dns=None, userns_mode=None, extra_hosts=None, oom_score_adj=None, dns_opt=None, shm_size=None, log_config={'Type': '', 'Config': {}}, group_add=None, pids_limit=None, pid_mode=None, ipc_mode=None, binds=[], memswap_limit=None, ulimits=None, security_opt=None, read_only=None, tmpfs=None, sysctls=None, mem_swappiness=None, mem_reservation=None, privileged=False, mem_limit=None, restart_policy=None, links=[], volumes_from=[], network_mode='media_default')
compose.cli.verbose_proxy.proxy_callable: docker create_host_config -> {'Binds': [],
 'Links': [],
 'LogConfig': {'Config': {}, 'Type': ''},
 'NetworkMode': 'media_default',
 'PortBindings': {'None/tcp': [{'HostIp': '', 'HostPort': ''}]},
 'VolumesFrom': []}
compose.service.create_container: Creating media_foo_1
compose.cli.verbose_proxy.proxy_callable: docker create_container <- (detach=True, volumes={}, name='media_foo_1', host_config={'VolumesFrom': [], 'NetworkMode': 'media_default', 'Links': [], 'Binds': [], 'Isolation': None, 'PortBindings': {'None/tcp': [{'HostIp': '', 'HostPort': ''}]}, 'LogConfig': {'Type': '', 'Config': {}}}, ports=[('None', 'tcp')], image='alpine', networking_config={'EndpointsConfig': {'media_default': {'IPAMConfig': {}, 'Aliases': ['foo']}}}, labels={'com.docker.compose.service': 'foo', 'com.docker.compose.oneoff': 'False', 'com.docker.compose.container-number': '1', 'com.docker.compose.config-hash': 'df12277d2b94980b1245953ec768c3916e94b9228becf2a5615e95a786b82771', 'com.docker.compose.version': '1.12.0', 'com.docker.compose.project': 'media'}, environment=[])
compose.parallel.parallel_execute_iter: Failed: <Service: foo>
compose.parallel.feed_queue: Pending: set()

ERROR: for foo  Cannot create container for service foo: invalid port specification: "None"
ERROR: compose.cli.main.main: Encountered errors while bringing up the project.

@shin-
Copy link

shin- commented Apr 19, 2017

It might be an issue with Python 3 - I'll take another look. In the meantime, you might want to try using Python 2.7 instead and see if the issue still occurs.

@drgroot
Copy link
Author

drgroot commented Apr 20, 2017

okay, switching to python 2 works.

@dalberto
Copy link

I've experienced the same issue on Python 3.5, installed via pip. Similarly, using python 2 fixes the issue. I experienced the issue with file versions 2.1 and 3.0, 3.2 but not 3.1.

@dpdornseifer
Copy link

dpdornseifer commented Apr 24, 2017

Hi experiencing the same problem just with Python3.5.0.
2.7 and 3.5.1 / 3.5.2 / 3.5.3 are working fine.
A quickfix for me right now is to to use docker-compose < 1.12.0

ghost pushed a commit to hyperledger/fabric-sdk-py that referenced this issue Apr 24, 2017
Running `make check` breaks right now when the testing dependency
`docker-compose` is installed in the version 1.12.0 (see the following
GitHub issue: docker/compose#4729).

Fixing the dependency to versions below 1.12.0 solves the problems and
`make check` will result in green tests again.

Change-Id: I62d83a1ef4495bae3699c2f89deecf213be82364
Signed-off-by: dpdornseifer <david.paul.dornseifer@sap.com>
@shin- shin- added this to the 1.14.0 milestone May 5, 2017
@shin-
Copy link

shin- commented May 5, 2017

I believe this Python bug is the cause of the issue: https://bugs.python.org/issue24931
Upgrading to Python 3.4.4+ or 3.5.1+ should fix it.

@svitlanacs
Copy link

svitlanacs commented May 18, 2017

@dpdornseifer could you, please, share the command you used to downgrade the docker-compose?

Found it! For anybody interested in how to downgrade docker-compose, this link was useful for me: https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-16-04

@shin-
Copy link

shin- commented May 18, 2017

@svitlanacs Please note that a much better solution would be to upgrade your Python installation.

@svitlanacs
Copy link

svitlanacs commented May 18, 2017

@shin- absolutely. But I'm running Ubuntu 14.04, so downgrading docker-compose was a simpler solution.

@z3ntu
Copy link

z3ntu commented Jun 11, 2017

I also downgraded to 1.11.2 as the Python version on Ubuntu 14.04 is 3.4.3.

@harpcio
Copy link

harpcio commented Jan 8, 2018

I have the same issue on python 2.7.6 / ubuntu 14.04.05 LTS with docker-compose version: "2.1". Switching to version: '2' have fixed the problem.

@OleksiiStepanov
Copy link

OleksiiStepanov commented Nov 6, 2018

I had same error with my port map and i solved that. Just wrote a map as string

ports:
    - 8080:80
... 

replace with:

ports:
    - "8080:80"
...

i am using docker-compose version 1.21.2, build a133471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants