inveniosoftware / troubleshooting

DEPRECATED - Use the forum instead:
https://invenio-talk.web.cern.ch
5 stars 4 forks source link

How to start docker when installing Invenio as plain user #47

Closed fjorba closed 5 years ago

fjorba commented 5 years ago

When installing Invenio as a plain user, how do we start dockerd? If I start it as root, ex:

~# service docker start

when calling docker (https://invenio.readthedocs.io/en/latest/quickstart/quickstart.html#install), it do

$ docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

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

I haven't found any conclusive answer googling around.

Thanks

slint commented 5 years ago

@fjorba It seems like docker service is not running.

What OS are you running on? Have you installed docker via the official Docker installation guide?

EDIT: for Ubuntu you can follow these instructions

fjorba commented 5 years ago

I'm running Debian (testing, as Debian testing is now in the freeze state), and whenever there is a Debian package, I prefer to use it. In that case, I understand that the Docker and Docker compose are:

Docker is running as root:

root@si-164-14:~# service docker start
root@si-164-14:~# ps -ef | grep docker
root       911     1  0 15:21 ?        00:00:01 /usr/sbin/dockerd -H fd://
root      1327   911  0 15:21 ?        00:00:01 docker-containerd --config /var/run/docker/containerd/containerd.toml --log-level info
root      2969  2929  0 15:28 pts/1    00:00:00 grep docker
slint commented 5 years ago

ps -ef | grep -i docker gives me similar results on Ubuntu:

$ ps -ef | grep -i docker
root      6338     1  0 Mar13 ?        00:00:49 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

If docker run hello-world works (i.e. the docker example from docs works) then it might be an issue with docker-compose... On my machine docker-compose --version returns docker-compose version 1.23.2, build 1110ad0 (not sure if the version is the problem though...). Some suggest setting DOCKER_HOST=127.0.0.1, though I would expect defaults to work

fjorba commented 5 years ago

That's what I get:

$ docker-compose --version
docker-compose version 1.21.0, build unknown
$ docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

From what I have read, when running docker as root, normal users usually cannot access it. So I'm ready to run it as user. That's my question: how (which syntax) should I use to run dockerd when not helped by the service docker run root utility. There are so many options that I have no idea which ones to choose.

Thanks again

slint commented 5 years ago

Have you added your user to the docker group via sudo usermod -aG docker $(whoami)?

fjorba commented 5 years ago

That's it, great! After adding my account to the docker group, logging out and logging in; even rebooting, now the $ docker-compose up -d has started to download many things.

So, apparently, docker can be started as normal Debian service, as long as the plain user belongs to the docker group. So far, so good, thanks!