10
votes

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 <[email protected]>

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?

2
I don't see you exposing any ports on a docker, try exposing 873 or whatever rsync is using with d.expose = [873]German Rumm
still the same error messageWissem

2 Answers

2
votes

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.

1
votes

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)