Skip to content

Ubuntu docker compose doesn't work

Shuang edited this page Aug 23, 2017 · 1 revision

Ubuntu 下 docker 运行要 sudo,然而 docker-compose 不用,所以运行 docker-compose 时会报错

ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

问题解决方案是统一 docker 和 docker-compose 的权限,一个方法是不用 sudo 开启 docker,步骤如下:

  1. Add the docker group if it doesn't already exist: sudo groupadd docker
  2. Add the connected user "$USER" to the docker group. Change the user name to match your preferred user if you do not want to use your current user: sudo gpasswd -a $USER docker
  3. Either do a newgrp docker or log out/in to activate the changes to groups.

再试一下运行 docker info,发现问题就解决啦~

[[TOC]]

Clone this wiki locally