使用docker时遇到的问题,在这里记录一下。
Mac OS X 下安装使用 Docker
Docker是跑在Linux环境上的,所以如果不是 like Linux的系统怎么办呢?
- 安装虚拟机(建议VirtualBox)。(可选,因为如果用boot2docker,这个程序中直接包含了 VirtualBox 虚拟主机(VM), Docker 和 Boot2Docker 管理工具。就不需要另外安装VirtualBox了,也就是直接进行第二步了。)
- docker官网上针对macOSX的安装步骤https://docs.docker.com/mac/step_one/
完全按照官网的安装步骤一步一步来就好了。原来安装的是boot2docker工具,但是最近被docker-machine取代了。
Bug1
Get http:///var/run/docker.sock/v1.17/images/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
- Openstack上的答案:Docker: Are you trying to connect to a TLS-enabled daemon without TLS?
- 在boot2docker up时提醒要设置 export 的三个属性,或者用boot2docker shellinit命令来 attach a shell to boot2docker
方法一:使用 shell 命令来设置环境变量。
$ eval "$(boot2docker shellinit)"
方法二:或者如果你是用的 bash 的话,把错误中提示的export,写到 ~/.bash_profile 中
# Set docker
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/muzilan/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1d
Bug2
pull image 的时候出现:Layer already being pulled by another client. Waiting. 出现上述错误然后就卡住了,总是pull不成功
搜了搜,看到有人说这是 1.8版本的一个bug,会在1.9版本中修复。看了看stackoverflow和github上的讨论,并没有很好的解决方法。可以尝试,关掉所有的docker-machine,或boot2docker ,并且重启机器。
stackoverflow上的讨论:Docker: how to fix “Layer already being pulled by another client. Waiting”
里面的答案说的也就是重启boot2docker
boot2docker stop
boot2docker upgithub上的讨论:Docker can hang indefinitely waiting for a nonexistant process to pull an image. #12823