【问题标题】:Vagrant: boot2docker: Unable to find image 'drupal' locallyVagrant:boot2docker:无法在本地找到图像“drupal”
【发布时间】:2016-09-07 21:58:29
【问题描述】:

我尝试在 Vagrant box boot2docker(在 Windows 8.1 上)中将 Drupal 作为 Docker 容器运行。

Vagrantfile(Drupal 容器)

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.provider "docker" do |docker|
    docker.vagrant_vagrantfile = "host/Vagrantfile"
    docker.image = "drupal"
    docker.ports = ['80:80']
    docker.name = 'drupal-container'
  end
  config.vm.synced_folder ".", "/vagrant", type: "smb", disabled: true
end

主机/Vagrantfile (boot2docker)

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "mitchellh/boot2docker"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.provision "docker"
  config.vm.hostname = "docker-host"
end

在我的 Drupal 容器目录中运行 vagrant up 会导致错误,因为找不到“drupal”图像。

输出

Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
    default: Vagrant will now create or start a local VM to act as the Docker
    default: host. You'll see the output of the `vagrant up` for this VM below.
    default:
    default: Importing base box 'mitchellh/boot2docker'...
    default: Matching MAC address for NAT networking...
    default: Checking if box 'mitchellh/boot2docker' is up to date...
    default: Setting the name of the VM: boot2docker_default_1463038875167_93224
    default: Clearing any previously set network interfaces...
    default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Forwarding ports...
    default: 2375 (guest) => 2375 (host) (adapter 1)
    default: 80 (guest) => 8080 (host) (adapter 1)
    default: 22 (guest) => 2222 (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:2222
    default: SSH username: docker
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
    default: Machine booted and ready!
No installation found.
The guest's platform ("tinycore") is currently not supported, will try generic Linux method...
Copy iso file C:\Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
Installing Virtualbox Guest Additions 5.0.20 - guest version is unknown
mkdir: can't create directory '/tmp/selfgz80627365': No such file or directory
Cannot create target directory /tmp/selfgz80627365
You should try option --target OtherDirectory
An error occurred during installation of VirtualBox Guest Additions 5.0.20. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
    default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
    default: Setting hostname...
    default: Running provisioner: docker...
==> default: Warning: When using a remote Docker host, forwarded ports will NOT be
==> default: immediately available on your machine. They will still be forwarded on
==> default: the remote machine, however, so if you have a way to access the remote
==> default: machine, then you should be able to access those ports there. This is
==> default: not an error, it is only an informational message.
==> default: Creating the container...
    default:   Name: drupal-container
    default:  Image: drupal
    default:   Port: 80:80
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" "run" "--name" "drupal-container" "-d" "-p" "80:80" "drupal"

Stderr: Unable to find image 'drupal' locally
Pulling repository drupal
2016/05/12 07:42:05 Could not reach any registry endpoint

Stdout:

如果我将主机的框更改为ubuntu/trusty64,它可以工作

host/Vagrantfile (ubuntu/trusty64)

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.provision "docker"
  config.vm.hostname = "docker-host"
end

但我喜欢用boot2docker,因为它更轻量级。

我的 vagrant 配置有什么问题?如何让 boot2docker 盒子作为主机工作?

【问题讨论】:

    标签: drupal docker vagrant boot2docker


    【解决方案1】:

    我实际上无法使您的配置正常工作,但我已经测试了mitchellh/boot2docker 框并发现了问题。 docker version 在该框中的输出是:

    Client version: 1.2.0
    Client API version: 1.14
    Go version (client): go1.3.1
    Git commit (client): fa7b24f
    OS/Arch (client): linux/amd64
    Server version: 1.2.0
    Server API version: 1.14
    Go version (server): go1.3.1
    Git commit (server): fa7b24f
    

    这个版本的 docker 已经过时了,现在根本无法从 docker hub 拉取镜像。您可以在此处查看 docker 团队宣布弃用的位置:https://blog.docker.com/2015/10/docker-hub-deprecation-1-5/

    目前您必须拥有 docker >= 1.6 才能从 docker hub 拉取图像。

    【讨论】:

    • 补充一下 - 在第二种情况下,你只是在你的 ubuntu 虚拟机上安装 docker,而不是拉任何图像
    • 我认为他们还在使用帖子顶部的 drupal Vagrantfile。虽然我无法让双 vagrantfile 设置为我工作。
    • 您不能同时使用 docker 提供程序和配置 - 要么您在您定义的系统(ubuntu/centos ...)上使用 docker 配置,它将在此 VM 上安装 docker 并拉取图像等...或者您使用 docker 提供程序,它将在 boot2docker VM 上提升 docker(不确定 vagrant 是否有计划支持本机 docker,现在它已经宣布用于 mac/windows)
    • 你会推荐什么盒子?
    • 我现在用hashicorp/boot2docker
    猜你喜欢
    • 2016-08-04
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 2018-04-18
    • 2021-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多