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

_get_legacy_containers_iter() TypeError: argument of type 'NoneType' is not iterable #1694

Closed
ChrisRut opened this issue Jul 14, 2015 · 22 comments
Assignees
Labels

Comments

@ChrisRut
Copy link

I just upgraded from 1.1.0 to 1.3.2, and after dealing with the /tmp directory being mounted as noexec (issue #1339), I ran into another issue that I couldn't find in the backlog;

$ docker-compose up -d
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 32, in main
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 34, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 66, in perform_command
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 471, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.project", line 230, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 398, in remove_duplicate_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 405, in duplicate_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 112, in containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.legacy", line 56, in check_for_legacy_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.legacy", line 138, in get_legacy_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.legacy", line 152, in _get_legacy_containers_iter
TypeError: argument of type 'NoneType' is not iterable

Downgrading to 1.3.1 seems to alleviate this behavior.

@dnephin
Copy link

dnephin commented Jul 14, 2015

Which docker version are you using? In docker 1.6 "no labels" is an empty mapping, but this errors seems like it's returning null instead of the empty mapping.

@ChrisRut
Copy link
Author

My docker version:

Docker version 1.6.2, build 7c8fca2

I suspect this pull is related: #1643

@chaos95
Copy link

chaos95 commented Jul 15, 2015

Can confirm the same behaviour - Docker version 1.6.2, build 7c8fca2.
Upgraded from docker-compose 1.1.0 to 1.3.2 via pip install -U docker-compose and I get the following result from docker-compose migrate-to-labels:

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.3.2', 'console_scripts', 'docker-compose')()
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 32, in main
    command.sys_dispatch()
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/docopt_command.py", line 21, in sys_dispatch
    self.dispatch(sys.argv[1:], None)
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 34, in dispatch
    super(Command, self).dispatch(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/docopt_command.py", line 24, in dispatch
    self.perform_command(*self.parse(argv, global_options))
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 66, in perform_command
    handler(project, command_options)
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 515, in migrate_to_labels
    legacy.migrate_project_to_labels(project)
  File "/usr/local/lib/python2.7/dist-packages/compose/legacy.py", line 121, in migrate_project_to_labels
    one_off=False,
  File "/usr/local/lib/python2.7/dist-packages/compose/legacy.py", line 138, in get_legacy_containers
    one_off=one_off,
  File "/usr/local/lib/python2.7/dist-packages/compose/legacy.py", line 152, in _get_legacy_containers_iter
    if LABEL_VERSION in container['Labels']:
TypeError: argument of type 'NoneType' is not iterable

@chaos95
Copy link

chaos95 commented Jul 15, 2015

Suggest simply prefixing the erroneous conditional on the last frame of that stacktrace (compose/legacy.py:152) with container['Labels'] and. If I get a chance later today I'll submit a PR myself, but I'm happy for someone to beat me to the punch!

@phemmer
Copy link

phemmer commented Jul 15, 2015

Seeing this with Docker version 1.7.0, build 0baf609, so it's not just a docker-1.6 issue.

@kacy
Copy link

kacy commented Jul 15, 2015

Can also confirm this same behavior with Docker version 1.7.0, build 0baf609 and Docker version 1.6.1, build 97cd073 with docker-compose version: 1.3.2. After reverting back to docker-compose version: 1.2.0, I no longer see the issue.

@dnephin
Copy link

dnephin commented Jul 15, 2015

I think the easy fix is to change container['Labels'] to container.get('Labels', {}), but I'm still not sure how this is happening, since it seems like the default empty value should always be the empty mapping {} not None.

Maybe this behaviour differs based on the version of docker that was used to create the container? Do you happen to know if the old containers were created with a version of docker < 1.6 ?

A paste of the docker inspect <container name> for one of the old containers would be really helpful for debugging this.

@buckett
Copy link

buckett commented Jul 15, 2015

I'm seeing this and I think had a set of container that I upgraded to labels with the docker-compose migrate-to-labels command.

@aanand
Copy link

aanand commented Jul 15, 2015

Got a fix in #1705, but agree - it'd be good to know where/why the API is doing this.

@aanand
Copy link

aanand commented Jul 16, 2015

Could anyone who's experiencing this issue please give one of these binaries a try? If they fix the problem, I'll release 1.3.3.

Mac: http://cl.ly/0N2g0J0r2a25/docker-compose-Darwin-x86_64
Linux: http://cl.ly/0F2x3v0N3C1p/docker-compose-Linux-x86_64

@buckett
Copy link

buckett commented Jul 16, 2015

Yep, works a treat for me thanks.

$ docker-compose ps
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 32, in main
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 34, in dispatch
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 66, in perform_command
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 196, in ps
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.project", line 310, in containers
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.legacy", line 56, in check_for_legacy_containers
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.legacy", line 138, in get_legacy_containers
  File "/compose/build/docker-compose/out00-PYZ.pyz/compose.legacy", line 152, in _get_legacy_containers_iter
TypeError: argument of type 'NoneType' is not iterable
$ ~/Downloads/docker-compose ps
               Name                                 Command                                State                                 Ports                
-----------------------------------------------------------------------------------------------------------------------------------------------------
sakaidev_app_1                        /opt/scripts/entrypoint.sh ...        Up                                    127.0.0.1:10001->10001/tcp,         
                                                                                                                  127.0.0.1:5400->5400/tcp,           
                                                                                                                  127.0.0.1:8000->8000/tcp,        

@elghazal-a
Copy link

Thanks @aanand Docker-compose for Linux-x86_64 works for me

@aanand
Copy link

aanand commented Jul 16, 2015

Great. This fix is now in Compose 1.3.3 - please update: https://github.com/docker/compose/releases/tag/1.3.3

@dgraver
Copy link

dgraver commented Jul 16, 2015

Thank you! this worked great.

@chaos95
Copy link

chaos95 commented Jul 16, 2015

Thanks @aanand, works perfectly!

stain added a commit to openphacts/ops-platform-setup that referenced this issue Jul 21, 2015
@faxik
Copy link

faxik commented Aug 20, 2015

I've come to this as I got the same error in

docker-compose up

even with minimal .yml file

I tried the newer version, and I'm getting the error:

$ docker-compose-Linux-x86_64 up
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 32, in main
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 34, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 66, in perform_command
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 471, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.project", line 245, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 318, in execute_convergence_plan
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 212, in create_container
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 232, in ensure_image_exists
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 247, in image
  File "/code/build/docker-compose/out00-PYZ.pyz/docker.utils.decorators", line 20, in wrapped
  File "/code/build/docker-compose/out00-PYZ.pyz/docker.client", line 481, in inspect_image
AttributeError: 'list' object has no attribute 'replace'

I updated all the images, the problem still exists.

@d3ming
Copy link

d3ming commented Aug 21, 2015

I'm getting this error (or at least a very similar one) with docker-compose 1.3.3 with docker 1.6.2 (on circleci):

Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.3.3', 'console_scripts', 'docker-compose')()
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 32, in main
    command.sys_dispatch()
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/docopt_command.py", line 21, in sys_dispatch
    self.dispatch(sys.argv[1:], None)
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 34, in dispatch
    super(Command, self).dispatch(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/docopt_command.py", line 24, in dispatch
    self.perform_command(*self.parse(argv, global_options))
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/command.py", line 66, in perform_command
    handler(project, command_options)
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 471, in up
    timeout=timeout
  File "/usr/local/lib/python2.7/dist-packages/compose/project.py", line 245, in up
    timeout=timeout
  File "/usr/local/lib/python2.7/dist-packages/compose/service.py", line 318, in execute_convergence_plan
    do_build=do_build,
  File "/usr/local/lib/python2.7/dist-packages/compose/service.py", line 225, in create_container
    return Container.create(self.client, **container_options)
  File "/usr/local/lib/python2.7/dist-packages/compose/container.py", line 38, in create
    response = client.create_container(**options)
  File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 245, in create_container
    return self.create_container_from_config(config, name)
  File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 252, in create_container_from_config
    res = self._post_json(u, data=config, params=params)
  File "/usr/local/lib/python2.7/dist-packages/docker/clientbase.py", line 128, in _post_json
    return self._post(url, data=json.dumps(data2), **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/clientbase.py", line 83, in _post
    return self.post(url, **self._set_request_timeout(kwargs))
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 508, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 433, in send
    raise ReadTimeout(e, request=request)

@aanand
Copy link

aanand commented Aug 24, 2015

@d3ming That doesn't look similar to me - it looks like a connection error (specifically, a timeout).

@d3ming
Copy link

d3ming commented Aug 24, 2015

@aanand ah OK - I was looking from the top of the callstack and it looked similar but I see whaty ou mean now. Any other insight from the callstack? (like what is it trying to connect to when it fails)?

Should this be treated as a separate bug?

@aanand
Copy link

aanand commented Aug 25, 2015

@d3ming It looks like it happened when performing the API call to create a container. I don't know if we can stop it from happening, because I don't know what's causing it - it could be a transient networking issue on your end.

In any case, it's definitely a separate issue, yes.

@d3ming
Copy link

d3ming commented Aug 25, 2015

Got it - opened #1923

@HuKeping
Copy link

HuKeping commented Sep 8, 2015

I'm getting this with docker-compose up

Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 39, in main
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 27, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 59, in perform_command
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 495, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.project", line 251, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 446, in remove_duplicate_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 453, in duplicate_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 110, in containers
TypeError: 'NoneType' object is not iterable

The docker-compose.yml is like

projectname:
        build: .
        ports:
                - "9999:9999"

The version of docker-compose is:

docker-compose version: 1.4.0

stain added a commit to openphacts/ops-docker that referenced this issue Feb 8, 2016
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