2

我没有成功通过 Windows 上的 Vagrant 提供 dockerfile。如果我使用图像(例如d.image = "phusion/baseimage"build_dir一切都很好 - 但是从 dockerfile 构建时(如下面的 vagrantfile 所示) - 我收到以下错误(当然我有一个Dockerfilein infrastructure/ssh-docker!):

PS C:\privat\cloud-backup\cloud-backup-for-podio> vagrant up
Bringing machine 'app' up with 'docker' provider...
==> app: Docker host is required. One will be created if necessary...
    app: Docker host VM is already ready.
==> app: Syncing folders to the host VM...
    app: Preparing SMB shared folders...
    app: Mounting SMB shared folders...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/guests/linux/cap/choose_addressable_ip_addr.rb:7:in `block
 in choose_addressable_ip_addr': undefined method `each' for nil:NilClass (NoMethodError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/guests/linux/cap/choose_addressable_ip_addr.rb:6:in `tap'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/guests/linux/cap/choose_addressable_ip_addr.rb:6:in `choose_addressable_ip_addr'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/capability_host.rb:111:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/capability_host.rb:111:in `capability'
        ...

流浪文件:

Vagrant.configure("2") do |config

  config.ssh.username = 'vagrant'
  config.ssh.password = 'tcuser'
  config.ssh.port = 22

  config.vm.define "app" do |app|
    app.vm.synced_folder ".", "/vagrant", type: "smb", smb_host: "MY_IP", smb_username: "WINUSER@DOMAIN", smb_password: "WINPASSWORD"
    app.vm.provider "docker" do |d|
      #d.image = "phusion/baseimage"
      d.build_dir = "infrastructure/ssh-docker"
      d.name = "app"
      d.remains_running = true
    end
  end

end

Dockerfile:

FROM phusion/baseimage

ENV HOME /root

# enable ssh
RUN rm -f /etc/service/sshd/down

# Regenerate SSH host keys. baseimage-docker does not contain any, so you
# have to do that yourself. You may also comment out this instruction; the
# init system will auto-generate one during boot.
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

RUN apt-get update

RUN apt-get install -y openssh-server wget lsb-release sudo

EXPOSE 22

RUN mkdir -p /var/run/sshd
RUN chmod 0755 /var/run/sshd

# Create and configure vagrant user
RUN useradd --create-home -s /bin/bash vagrant
WORKDIR /home/vagrant

# Configure SSH access
RUN mkdir -p /home/vagrant/.ssh
RUN echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /home/vagrant/.ssh/authorized_keys
RUN chown -R vagrant: /home/vagrant/.ssh
RUN echo -n 'vagrant:vagrant' | chpasswd

# Enable passwordless sudo for the "vagrant" user
RUN mkdir -p /etc/sudoers.d
RUN install -b -m 0440 /dev/null /etc/sudoers.d/vagrant
RUN echo 'vagrant ALL=NOPASSWD: ALL' >> /etc/sudoers.d/vagrant

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

流浪者版本:1.7.4

有人有什么想法吗?

(我需要做的是从 dockerfile 运行一个 docker 映像并拥有一个共享/同步目录..)

4

1 回答 1

0

您应该为 smb 服务提供您的 ip

config.vm.synced_folder ".", "/home/vagrant/github-api", 类型: 'smb', smb_host: "192.168.1.100"

于 2015-10-02T20:32:33.707 回答