今天在服务器上安装docker并执行

docker-compose up -d

命令时,报错如下:

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

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

解决方法如下:

  1. 执行如下命令将当前用户加入docker用户组:

    sudo gpasswd -a ${USER} docker
    
  2. 将当前用户切换到root,然后再切换回来,比如当前用户为ubuntu,执行如下命令:

    // 切换到root用户
    sudo su
    // 从root用户切换回ubuntu用户
    su ubuntu
    
  3. 再执行如下命令就不会报错了

    docker-compose up -d
    
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐