流浪者和码头供应商

人气:760 发布:2022-09-21 标签: docker virtualbox vagrant

问题描述

此问题也已发布到Vagrant Google Group。

This question has also been posted to the Vagrant Google Group.

我的环境:

OS-X 10.9.4
VirtualBox 5.012 r104815
Vagrant 1.7.4

尝试使用码头提供商,主机是geerlingguy / centos7

Trying to use docker provider, with the host machine being geerlingguy/centos7

通过放置:

config.vm.provision "docker"

在主机vagrant文​​件它自动配置我的主机与以下码头版本:

in host machine vagrant file it auto configures my host machine with the following docker version:

Version:      1.8.2-el7.centos
API version:  1.20
Package Version: docker-1.8.2-10.el7.centos.x86_64
Go version:   go1.4.2
Git commit:   a01dc02/1.8.2
Built:
OS/Arch:      linux/amd64

Server:
Version:      1.8.2-el7.centos
API version:  1.20
Package Version:
Go version:   go1.4.2
Git commit:   a01dc02/1.8.2
Built:
OS/Arch:      linux/amd64

我可以从中心运行docker容器,但是当我尝试从Dockerfile中构建docker容器时,我得到:

I can run docker containers from hub but when I try to build docker container from Dockerfile I get:

Command: "docker" "build" "/var/lib/docker/docker_build_1b35c3f0278e1a3b37d1578d7ce326e5"

Stderr:

Stdout: unable to prepare context: unable to evaluate symlinks in context path: lstat /var/lib/docker/docker_build_1b35c3f0278e1a3b37d1578d7ce326e5: permission denied

如果我将ssh移动到centos7主机并运行

If I vagrant ssh into centos7 host and run

docker build /var/lib/docker/docker_build_1b35c3f0278e1a3b37d1578d7ce326e5 

我看到同样的错误,但如果我运行

I see same error but if I run

sudo docker build /var/lib/docker/docker_build_1b35c3f0278e1a3b37d1578d7ce326e5 

构建运行。

I尝试:

config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'

为主机,但是它没有找到docker命令。

for host machine but then it doesn't find docker command.

也许我应该添加我在做这在主机vagrantfile中:

Maybe I should add I am doing this in the host vagrantfile:

 # Ensure vagrant user can run docker command
  config.vm.provision "shell", inline: "sudo groupadd docker;true"
  config.vm.provision "shell", inline: "sudo usermod -a -G docker vagrant;true"
  config.vm.provision "shell", inline: "docker version"
  config.vm.provision :reload

和vagrant可以运行码头工作者。

and vagrant can run docker.

这是它落在哪里(在docker vagrant文​​件中):

This is where it falls over (in the docker vagrant file):

 config.vm.provider "docker" do |docker|
     docker.build_dir = /path/to/my/dockerfile/on/the/host/vm (FAILS WITH symlink ERROR)
  end

config.vm.provider "docker" do |docker|
    docker.image = hub/image
end

将成功创建容器。

我一直在敲我的头2天 - 在虚拟框中阅读有关符号链接问题的各种各样的设置。尝试各种不同的设置。

I have been banging my head for 2 days - reading all sorts about symlink issues in virtualbox and tried all sorts of different settings.

有人可以建议我如何解决这个问题。

Can anybody advise how I should resolve this.

谢谢。

推荐答案

我的解决方案是在/ usr / bin / docker上设置粘码。

My solution was to set sticky bit on /usr/bin/docker.

这允许docker遵循sym链接并完成docker build 。不清楚,而不是完全确定错误在哪里。我基本上按照推荐的工作流程来建造有流浪汉的码头货柜。

This allowed docker to follow sym links and complete docker build. Obscure, and not totally sure where the fault lies. I was basically following the recommended workflow for building docker containers with vagrant.

281