7

I was doing the django-shop tutorial from this link:https://django-shop.readthedocs.io/en/latest/tutorial/quickstart.html . I am very new in docker ,docker-compose and linux .

I get this error:

ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:2375 - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

When I execute these commands...

$ git clone --depth 1 github.com/awesto/django-shop 
$ cd django-shop 
$ export DJANGO_SHOP_TUTORIAL=commodity 
$ docker-compose up --build -d

I tried to do this Tutorial and this didn't work.

EDIT: I use this Command to solve this problem:

$ sudo adduser razvan docker

4
  • 1
    What steps did you take to encounter this issue? Do you know for certain that the Docker daemon is at a different IP/port? Aug 16, 2018 at 13:31
  • 1
    $ git clone --depth 1 github.com/awesto/django-shop $ cd django-shop $ export DJANGO_SHOP_TUTORIAL=commodity $ docker-compose up --build -d Aug 16, 2018 at 13:52
  • I used these steps Aug 16, 2018 at 13:53
  • 1
    Thank, Razvan! I submitted an edit to add them to your question. Unfortunately, I don't know enough about Docker to help. But hopefully the extra context will help someone else provide an answer. Aug 16, 2018 at 13:54

3 Answers 3

7

As a general rule, never set DOCKER_HOST.

Given your error message, it looks like it might be set (incorrectly) and you might see if things get better if you

unset DOCKER_HOST

The two prominent exceptions are VM-based Docker environments (Docker Toolbox, Docker Machine, Kubernetes' minikube). In these cases there are helper scripts that can set it to the correct value:

eval $(docker-machine env)   # Docker Machine, Docker Toolbox
eval $(minikube docker-env)  # Minikube
3

By set DOCKER_HOST you tell for every run of docker in command line to use http api, instead of default - socket on localhost.

By default http api is turned off

$ sudo cat /lib/systemd/system/docker.service | grep ExecStart
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

you can add -H tcp://127.0.0.1:2375 for tern on http api on localhost but usually you want to tern on api for remote servers by -H tcp://0.0.0.0:2375 (!!! do it only with proper firewall !!!)

so you need to change in /lib/systemd/system/docker.service to next line

ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375 --containerd=/run/containerd/containerd.sock
0

I am using Ubuntu 16.04 so I went at the end of the /home/user/.profile file and placed the unset DOCKER_HOST command. Then sourced the file like so: source /home/user/.profile then logged out and logged back in and docker now works normally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.