链接docker-compose到本地docker守护进程

时间:2016-02-04 15:36:27

标签: docker docker-compose

我将在Ubuntu“服务器”上运行docker-compose。 首先,我尝试了默认安装。 $DOCKER_HOST未定义。然后我将其设置为unix:///var/run/docker.sock

我一直都有:

$ docker-compose up
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.

启动了docker守护程序,我的docker-compose.yml在Mac安装上运行正常。

供参考:

$ uname -a
Linux my-test 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"

$ netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      5025/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      5025/sshd

$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:12:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:12:04 UTC 2015
 OS/Arch:      linux/amd64

$ docker info
Containers: 0
Images: 4
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 4
 Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-57-generic
Operating System: Ubuntu 14.04.3 LTS
CPUs: 1
Total Memory: 490 MiB
Name: my-test
ID: YUQU:EUTG:XDDJ:F4KZ:COM6:H2AZ:LMOK:W4SR:BTXH:QEGS:6BLV:NIPQ
WARNING: No swap limit support

$ docker-compose version
docker-compose version 1.5.2, build 7240ff3
docker-py version: 1.6.0
CPython version: 2.7.6
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014

$ ls /var/run/dock*
/var/run/docker.pid  /var/run/docker.sock

/var/run/docker:
execdriver  netns

$ echo $DOCKER_HOST
unix:///var/run/docker.sock

1 个答案:

答案 0 :(得分:0)

您可能需要为Docker设置其他环境变量。一种简单的方法是在运行 docker-compose 之前运行命令bellow。

public class ClassA
{
  public ClassB InstanceOfClassB { get; set; }

  public ClassA()
  {
    InstanceOfClassB = new ClassB();
  }
  //More code here
}

public class ClassB
{
  //Code here
}