10

I'm trying to setup Vagrant with docker as a provider but when running

vagrant up --provider=docker --debug 

I get this error:

"rsync" was not detected as installed in your guest machine. This is required for rsync synced folders to work. In addition to this, Vagrant doesn't know how to automatically install rsync for your machine, so you must do this manually.

Full log here: http://pastebin.com/zCTSqibM

Vagrantfile

require 'yaml'

Vagrant.configure("2") do |config|

  user_config = YAML.load_file 'user_config.yml'

  config.vm.provider "docker" do |d|
    d.build_dir = "."
    d.has_ssh = true
    d.ports = user_config['port_mapping']
    d.create_args = ["--dns=127.0.0.1","--dns=8.8.8.8", "--dns=8.8.4.4"]
    d.build_args = ['--no-cache=true']   end

  config.vm.hostname = "dev"

  config.ssh.username = "it"   config.ssh.port = 22   config.ssh.private_key_path = ["./initial_ssh_key", user_config['ssh_private_key_path']]   config.ssh.forward_agent = true

end 

Dockerfile

FROM debian:jessie MAINTAINER IT <it@email.com>

RUN echo 'exit 0' > /usr/sbin/policy-rc.d

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

RUN apt-get update RUN apt-get upgrade -y RUN apt-get install sudo apt-utils -y

RUN apt-get -y install sysvinit-core sysvinit sysvinit-utils RUN cp /usr/share/sysvinit/inittab /etc/inittab RUN apt-get remove -y --purge
--auto-remove systemd libpam-systemd systemd-sysv

RUN apt-get install ssh -y

RUN addgroup --system it RUN adduser --system --disabled-password
--uid 1000 --shell /bin/bash --home /home/it it RUN adduser it it RUN adduser it sudo

RUN echo "it ALL=(ALL)  NOPASSWD: ALL" >> /etc/sudoers

ADD initial_ssh_key.pub /home/it/.ssh/authorized_keys RUN chown it:it /home/it/ -R RUN echo "Host * \n\tStrictHostKeyChecking no" >> /etc/ssh/ssh_config

CMD exec /sbin/init

Note: I'm on Mac OS X 10.12 and I've installed vagrant, virtualbox and docker I have rsync installed and added to my PATH in the host machine. Also, the same vagrant and docker configs works perfectly on a ubuntu host.

How do I install rsync in the guest machine? Or is something else wrong with my config? Any ideas?

Wissem
  • 1,705
  • 4
  • 16
  • 22

2 Answers2

2

You may want to give the alternative boot2docker box a try: https://github.com/dduportal/boot2docker-vagrant-box as it contains rsync while the hashicorp/boot2docker, which is used by default, seems to lack this!

If doing so, you must add the follwong line to your docker provider config (of course adopted to your system):

d.vagrant_vagrantfile = "../path/to/Vagrantfile"

This is because you're changing the docker provider host vm as described in the vagrant docker provider documentation.

AntiTiming
  • 2,094
  • 3
  • 22
  • 33
1

Try adding rsync to your Docker file, somewhere in one of your apt-get lines. Linux hosts use NFS by default, that's why it works on your Ubuntu.

Normally Vagrant tries to install rsync on a guest machine, if that fails - it notifies you with that error message. More info on vagrant website (3rd paragraph in "Prerequisites" chapter)

German Rumm
  • 5,782
  • 1
  • 25
  • 30
  • I've tried this already but doesn't seems to work: added ```RUN apt-get install rsync -y```in dockerfile, same error message. Something is wrong with vagrant / vbox :/ – Wissem Dec 03 '16 at 14:28
  • 1
    It's not `vbox` - you are using `docker` as a provider: `config.vm.provider "docker"` – German Rumm Dec 03 '16 at 21:58
  • any ideas why it's failing then? I'm seeing this in the logs just before the rsync error message : [default] GuestAdditions versions on your host (5.0.16) and guest (4.3.28 r100309) do not match. The guest's platform ("linux") is currently not supported, will try generic Linux method... Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso Installing Virtualbox Guest Additions 5.0.16 - guest version is 4.3.28 r100309 mkdir: can't create directory '/tmp/selfgz10164313': No such file or directory – Wissem Dec 04 '16 at 18:57