Docker-py: client.containers.run throws "function has no attribute run" error

Created on 16 Dec 2016  路  1Comment  路  Source: docker/docker-py

Here is my code:

    docker_client = docker.from_env()
    worker = docker_client.containers.run(<config>)

Here is the output:

delegation_1  | Traceback (most recent call last):
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 368, in trace_task
delegation_1  |     R = retval = fun(*args, **kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 623, in __protected_call__
delegation_1  |     return self.run(*args, **kwargs)
delegation_1  |   File "/opt/app/delegate.py", line 44, in delegate
delegation_1  |     worker = docker_client.containers.run(os.environ['KWORKER_IMAGE'], \
delegation_1  | AttributeError: 'function' object has no attribute 'run'

Docker version:
Docker version 1.12.3, build 6b644ec

Docker-py version:
'1.10.6'

kinquestion

Most helpful comment

Yes, this API was introduced in 2.0, but you're using docker-py 1.10.
If you'd like to install the newest version, you can do so by uninstalling docker-py (pip uninstall docker-py) then installing the docker package (pip install docker==2.0.0`)
If however you would like to keep using 1.10, you can find the documentation for that version here: http://docker-py.readthedocs.io/en/1.10.0/api/#containers

>All comments

Yes, this API was introduced in 2.0, but you're using docker-py 1.10.
If you'd like to install the newest version, you can do so by uninstalling docker-py (pip uninstall docker-py) then installing the docker package (pip install docker==2.0.0`)
If however you would like to keep using 1.10, you can find the documentation for that version here: http://docker-py.readthedocs.io/en/1.10.0/api/#containers

Was this page helpful?
0 / 5 - 0 ratings