最近处理Vagrant文件,尝试构建包含多个dockers(app,redis)的项目
这些是我正在使用的版本
Vagrant 1.8.1
hashicorp/boot2docker (virtualbox, 1.7.8)
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin15]
这也是我的流浪文件
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define 'app' do |app|
app.vm.provider "docker" do |d|
app.vm.synced_folder ".", "/vagrant", disabled: true
app.vm.provision "file", source: "~/.docker/config.json", destination: "~/.docker/config.json"
app.vm.provision "shell", inline: "sudo cp -R /home/vagrant/.docker /root/.docker"
app.vm.provision "shell", inline: "echo Hello"
d.build_dir = "."
d.remains_running = false
end
end
end
实际上我遇到了两个不同的问题
1)似乎在同步文件夹时提示输入密码,出于某种原因,我发现网上有人写过使用tcuser
作为密码而且有效。但是,我想没有这个,有什么建议吗?
2)我试图构建的docker镜像实际上引用了AWS ECR
上的私人docker registery上的另一个图像,因此我尝试上传.docker/config.json
以允许身份验证,但它不适用于我。
以下是我看到的输出
Bringing machine 'app' up with 'docker' provider...
==> app: Docker host is required. One will be created if necessary...
app: Vagrant will now create or start a local VM to act as the Docker
app: host. You'll see the output of the `vagrant up` for this VM below.
app:
default: Box 'hashicorp/boot2docker' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
default: Loading metadata for box 'hashicorp/boot2docker'
default: URL: https://atlas.hashicorp.com/hashicorp/boot2docker
default: Adding box 'hashicorp/boot2docker' (v1.7.8) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/hashicorp/boxes/boot2docker/versions/1.7.8/providers/virtualbox.box
default: Successfully added box 'hashicorp/boot2docker' (v1.7.8) for 'virtualbox'!
default: Importing base box 'hashicorp/boot2docker'...
default: Matching MAC address for NAT networking...
default: Checking if box 'hashicorp/boot2docker' is up to date...
default: Setting the name of the VM: docker-host_default_1455753187095_3647
default: Fixed port collision for 2375 => 2375. Now on port 2204.
default: Fixed port collision for 22 => 2222. Now on port 2205.
default: Clearing any previously set network interfaces...
default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Forwarding ports...
default: 2375 (guest) => 2204 (host) (adapter 1)
default: 22 (guest) => 2205 (host) (adapter 1)
default: Running 'pre-boot' VM customizations...
default: Booting VM...
default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2205
default: SSH username: docker
default: SSH auth method: password
default: Machine booted and ready!
==> app: Syncing folders to the host VM...
default: Installing rsync to the VM...
default: The machine you're rsyncing folders to is configured to use
default: password-based authentication. Vagrant can't script rsync to automatically
default: enter this password, so you'll likely be prompted for a password
default: shortly.
default:
default: If you don't want to have to do this, please enable automatic
default: key insertion using `config.ssh.insert_key`.
default: Rsyncing folder: /Users/xx/Projects/proj/ => /var/lib/docker/docker_build_930d43a6c182bc70b5cb41a97523c5c6
docker@127.0.0.1's password:
==> app: Building the container from a Dockerfile...
app: Sending build context to Docker daemon 557.1 kB
app: Sending build context to Docker daemon 1.114 MB
app: Sending build context to Docker daemon 1.671 MB
app: Sending build context to Docker daemon 2.228 MB
app: Sending build context to Docker daemon 2.785 MB
app: Sending build context to Docker daemon 3.342 MB
app: Sending build context to Docker daemon 3.899 MB
app: Sending build context to Docker daemon 4.456 MB
app: Sending build context to Docker daemon 5.014 MB
app: Sending build context to Docker daemon 5.571 MB
app: Sending build context to Docker daemon 6.128 MB
app: Sending build context to Docker daemon 6.685 MB
app: Sending build context to Docker daemon 7.242 MB
app: Sending build context to Docker daemon 7.799 MB
app: Sending build context to Docker daemon 8.356 MB
app: Sending build context to Docker daemon 8.913 MB
app: Sending build context to Docker daemon 9.47 MB
app: Sending build context to Docker daemon 10.03 MB
app: Sending build context to Docker daemon 10.58 MB
app: Sending build context to Docker daemon 11.14 MB
app: Sending build context to Docker daemon 11.7 MB
app: Sending build context to Docker daemon 12.26 MB
app: Sending build context to Docker daemon 12.81 MB
app: Sending build context to Docker daemon 13.37 MB
app: Sending build context to Docker daemon 13.93 MB
app: Sending build context to Docker daemon 14.48 MB
app: Sending build context to Docker daemon 15.04 MB
app: Sending build context to Docker daemon 15.6 MB
app: Sending build context to Docker daemon 16.15 MB
app: Sending build context to Docker daemon 16.71 MB
app: Sending build context to Docker daemon 17.27 MB
app: Sending build context to Docker daemon 17.83 MB
app: Sending build context to Docker daemon 18.38 MB
app: Sending build context to Docker daemon 18.94 MB
app: Sending build context to Docker daemon 19.5 MB
app: Sending build context to Docker daemon 20.05 MB
app: Sending build context to Docker daemon 20.61 MB
app: Sending build context to Docker daemon 21.17 MB
app: Sending build context to Docker daemon 21.73 MB
app: Sending build context to Docker daemon 22.28 MB
app: Sending build context to Docker daemon 22.84 MB
app: Sending build context to Docker daemon 23.4 MB
app: Sending build context to Docker daemon 23.95 MB
app: Sending build context to Docker daemon 24.51 MB
app: Sending build context to Docker daemon 25.07 MB
app: Sending build context to Docker daemon 25.62 MB
app: Sending build context to Docker daemon 26.18 MB
app: Sending build context to Docker daemon 26.74 MB
app: Sending build context to Docker daemon 27.3 MB
app: Sending build context to Docker daemon 27.85 MB
app: Sending build context to Docker daemon 28.18 MB
app: Sending build context to Docker daemon
app: Step 0 : FROM id.dkr.ecr.us-east-1.amazonaws.com/image:latest
app: Pulling repository id.dkr.ecr.us-east-1.amazonaws.com/image
app: Authentication is required.
A Docker command executed by Vagrant didn't complete successfully!
The command run along with the output from the command is shown
below.
Command: "docker" "build" "/var/lib/docker/docker_build_930d43a6c182bc70b5cb41a97523c5c6"
Stderr: Authentication is required.
Sending build context to Docker daemon 28.18 MB557.1 kB
Sending build context to Docker daemon
Step 0 : FROM id.dkr.ecr.us-east-1.amazonaws.com/image:latest
Pulling repository id.dkr.ecr.us-east-1.amazonaws.com/image
答案 0 :(得分:0)
我自己也很流浪。但是,我可以在docker provisioner之前使用vagrant中的shell配置程序从私有docker注册表中提取。
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder "./", "/vagrant", type: "smb"
config.vm.provision "docker"
config.vm.provision "shell", inline: "docker login --username='user' --password='pass' my-private-registry"
config.vm.provision "docker" do |d|
d.pull_images "my-private-registry-image"
end
end
对于rsync要求输入密码的问题,我认为您可以在使用sync_folders时设置密码,例如
config.vm.synced_folder "./", "/vagrant", type: "rsync", username: "user", password: "pass"
但是我不推荐这个,因为你的密码可供所有人查看。希望这有帮助