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

DOCKER_HOST is not respected #84

Open
ssbarnea opened this issue Jan 27, 2021 · 7 comments
Open

DOCKER_HOST is not respected #84

ssbarnea opened this issue Jan 27, 2021 · 7 comments

Comments

@ssbarnea
Copy link
Member

I do have a DOCKER_HOST=ssh://[email protected] which is correctly used by all docker tools, including the docker-py python library. Still, tox-docker does not seem to rely on it and fails to run, thorwin an exception like:

  File "/Users/ssbarnea/c/os/git-review/.tox/.tox/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/ssbarnea/c/os/git-review/.tox/.tox/lib/python3.9/site-packages/tox_docker.py", line 204, in tox_runtest_pre
    docker.images.pull(name, tag=tag or None)
  File "/Users/ssbarnea/c/os/git-review/.tox/.tox/lib/python3.9/site-packages/docker/models/images.py", line 446, in pull
    pull_log = self.client.api.pull(
  File "/Users/ssbarnea/c/os/git-review/.tox/.tox/lib/python3.9/site-packages/docker/api/image.py", line 430, in pull
    self._raise_for_status(response)
  File "/Users/ssbarnea/c/os/git-review/.tox/.tox/lib/python3.9/site-packages/docker/api/client.py", line 270, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/Users/ssbarnea/c/os/git-review/.tox/.tox/lib/python3.9/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.ImageNotFound: 404 Client Error for http+docker://ssh/v1.41/images/create?tag=latest&fromImage=gerrit: Not Found ("pull access denied for gerrit, repository does not exist or may require 'docker login': denied: requested access to the resource is denied")

From the same machine doing a docker pull worked without any problems.

# tox.ini
[tox]
requires =
  tox-docker
  # unless paramiko is mentioned, we would get another error
  paramiko

[docker:gerrit]
image = docker.io/gerritcodereview/gerrit:3.3.1

[testenv:int]
docker =
  gerrit
commands = echo yep!
@ssbarnea
Copy link
Member Author

It seems that this bug was fixed in v2.0.0a3 pre-release, but that was like more than 6 months ago. Maybe it would make sense to tag a release.

@dcrosta
Copy link
Member

dcrosta commented Jan 27, 2021

Ugh, sorry about that. I meant to cut the release ... many months ago. 2020 caught up with me. Anyway, https://github.com/tox-dev/tox-docker/releases/tag/v2.0.0 is out the door and https://pypi.org/project/tox-docker/2.0.0/ is published. Let me know if this bug still exists on 2.0, but it seems like it shouldn't.

@chayim
Copy link

chayim commented May 27, 2021

I have a similar issue in the latest 3.0.0 release. In CircleCI (and others) DOCKER_HOST is set to the remote docker:

circleci@e6187b8d02f3:~/project$ echo $DOCKER_HOST
tcp://34.70.249.139:2376

But running tox with tox-docker yields the standard Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. It would appear that docker.from_env isn't honouring default settings, in our context.

In case it helps, here's the output of my poetry.lock, after a fresh install - with nothing pinned.

circleci@e6187b8d02f3:~/project$ cat poetry.lock |grep docker
name = "docker"
name = "tox-docker"
description = "Launch a docker instance around test runs"
docker = ">=2.3.0,<5.0"
docker = [
    {file = "docker-4.4.4-py2.py3-none-any.whl", hash = "sha256:f3607d5695be025fa405a12aca2e5df702a57db63790c73b927eb6a94aac60af"},
    {file = "docker-4.4.4.tar.gz", hash = "sha256:d3393c878f575d3a9ca3b94471a3c89a6d960b35feb92f033c0de36cc9d934db"},
tox-docker = [
    {file = "tox-docker-3.0.0.tar.gz", hash = "sha256:ed5bd518bdb8af818164bec6afb71cc5e196a78ca8f47162d83a36d183db3354"},
    {file = "tox_docker-3.0.0-py2.py3-none-any.whl", hash = "sha256:f7a17a1d89f61a4f47baf7ecfd9449ca7f510d1dd3e70ce9861025b71b907671"},

It goes without saying that docker ps runs properly.

@chayim
Copy link

chayim commented May 27, 2021

This happens with 2.0.0 as well.

@dcrosta
Copy link
Member

dcrosta commented Jun 6, 2021

How are you running tox?

@chayim
Copy link

chayim commented Jun 6, 2021

Standard command line run (tox -e ) via a virtualenv.

@dcrosta
Copy link
Member

dcrosta commented Jun 6, 2021

I wonder if something is preventing the env var from getting through. DOCKER_HOST should work as expected. Could you try using passenv or setenv in your tox.ini, let me know if that works? Or add something like action.setactivity("docker", f"env is {os.environ}") into about here: https://github.com/tox-dev/tox-docker/blob/master/tox_docker/__init__.py#L243

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

No branches or pull requests

3 participants