本文介绍了DOCKER_HOST变量做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手,在OSX上使用Boot2Docker。引导它后,会显示以下消息:

 要将Docker客户端连接到Docker守护程序,请设置
export DOCKER_HOST = tcp://192.168.59.103:2375

即使没有它,基本的Docker命令, docker运行hello-world )工作正常。



安装说明不是很丰富:

 注意:如果您在终端中看到如下消息:
将Docker客户端连接到Docker守护程序,请设置:
export DOCKER_HOST = tcp://192.168.59.103:2375
您可以按照指示安全地设置环境变量。

知道这是安全并不说明为什么它很有用。



我不清楚:


  1. 什么是docker客户端?

  2. 什么是docker守护进程?

  3. 什么是dockerhost? (Boot2Docker VM本身?)


解决方案

好的,我想我得到了。 p>

客户端是安装在OS X中的 docker 命令。



主机是Boot2Docker VM。



守护程序是一个背景服务运行在Boot2Docker内。



此变量告诉客户端如何连接守护进程。



启动Boot2Docker ,弹出的终端窗口已经设置了 DOCKER_HOST ,这就是为什么 docker 命令工作。但是,要在其他终端窗口中运行Docker命令,您需要在这些窗口中设置此变量



像这样:

  $ docker运行hello-world 
2014/08/11 11:41:42发布http: ///var/run/docker.sock/v1.13/containers/create:
拨号unix /var/run/docker.sock:没有这样的文件或目录

一种解决方法是简单地做到这一点:

  $ export DOCKER_HOST = tcp://192.168.59.103:2375 

但是,其他人最好这样做:

  $ $(boot2docker shellinit)
$ docker运行hello-world
Docker你好。 [...]

要解释这个可能非直观的Bash命令,运行 boot2docker shellinit 返回一组设置环境变量的Bash命令:

  export DOCKER_HOST = tcp ://192.168.59.103:2376 
export DOCKER_CERT_PATH = / Users / ddavison / .boot2docker / certs / boot2docker-vm
export DOCKER_TLS_VERIFY = 1

因此,运行 $(boot2docker shellinit)生成这些命令,然后运行它们 。


I'm new to Docker, using Boot2Docker on OSX. After booting it, this message is given:

To connect the Docker client to the Docker daemon, please set
export DOCKER_HOST=tcp://192.168.59.103:2375

Yet even without it, basic Docker commands (eg, docker run hello-world) work fine.

The install instructions aren't very informative:

Note: If you see a message in the terminal that looks something like this:
To connect the Docker client to the Docker daemon, please set:
export  DOCKER_HOST=tcp://192.168.59.103:2375
you can safely set the evironment variable as instructed.

Knowing that it's "safe" doesn't say why it's useful.

What I'm not clear on:

  1. What is the docker "client"?
  2. What is the docker "daemon"?
  3. What is the docker "host"? (The Boot2Docker VM itself?)
解决方案

Ok, I think I got it.

The client is the docker command installed into OS X.

The host is the Boot2Docker VM.

The daemon is a background service running inside Boot2Docker.

This variable tells the client how to connect to the daemon.

When starting Boot2Docker, the terminal window that pops up already has DOCKER_HOST set, so that's why docker commands work. However, to run Docker commands in other terminal windows, you need to set this variable in those windows.

Failing to set it gives a message like this:

$ docker run hello-world
2014/08/11 11:41:42 Post http:///var/run/docker.sock/v1.13/containers/create:
dial unix /var/run/docker.sock: no such file or directory

One way to fix that would be to simply do this:

$ export DOCKER_HOST=tcp://192.168.59.103:2375

But, as pointed out by others, it's better to do this:

$ $(boot2docker shellinit)
$ docker run hello-world
Hello from Docker. [...]

To spell out this possibly non-intuitive Bash command, running boot2docker shellinit returns a set of Bash commands that set environment variables:

export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/ddavison/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1

Hence running $(boot2docker shellinit) generates those commands, and then runs them.

这篇关于DOCKER_HOST变量做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:24