docker / docker-py

A Python library for the Docker Engine API
https://docker-py.readthedocs.io/
Apache License 2.0
6.85k stars 1.67k forks source link

docker.client.APIerror Client Error Not Found inside docker #2432

Open matbrgz opened 5 years ago

matbrgz commented 5 years ago

Env WSL2 Ubuntu1804

dockerfile
RUN pip install colorama==0.3.1 requests docker==4.0.2 psutil
Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/FrameworkBenchmarks/toolset/utils/docker_helper.py", line 155, in watch_container
    for line in docker_container.logs(stream=True):
  File "/usr/local/lib/python2.7/dist-packages/docker/models/containers.py", line 302, in logs
    return self.client.api.logs(self.id, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/container.py", line 853, in logs
    output = self._get_result(container, stream, res)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 451, in _get_result
    return self._get_result_tty(stream, res, self._check_is_tty(container))
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 447, in _check_is_tty
    cont = self.inspect_container(container)
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/container.py", line 756, in inspect_container
    self._get(self._url("/containers/{0}/json", container)), True
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 267, in _result
    self._raise_for_status(response)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 263, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
NotFound: 404 Client Error: Not Found ("No such container: ba9ec13ceecc81280dd28c9bd3ce042b5e90ca602dd4941bc649d5c1fb54ea25")
docker_helper.py, line 150:156
def watch_container(docker_container, docker_file):
                with open(
                        os.path.join(
                            run_log_dir, "%s.log" % docker_file.replace(
                                ".dockerfile", "").lower()), 'w') as run_log:
                    for line in docker_container.logs(stream=True):
                        log(line, prefix=log_prefix, file=run_log)

I'm using last version (running through #https://github.com/docker/docker-py/issues/188)

feliperuhland commented 5 years ago

Hi @MatheusRV.

The error No such container could occur because your container stopped before the watch_container execution.

Can you provide more information about it?