Closed electrofelix closed 5 years ago
Can you post a example Vagrantfile as well?
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# auto detect the docker address for this host
docker_gateway = Socket.getifaddrs.select { |addr_info|
addr_info.name == "docker0" and addr_info.addr.ipv4?
}.first.addr.ip_address
config.vm.box = nil
config.vm.provider :docker do |d|
d.name = "docker-test"
d.image = "vagrant-ubuntu:16.04"
d.create_args = [
# needed to run /sbin/init as cmd
"--privileged",
# ensure container sends dns requests to the correct address
# to be picked up by landrush
"--dns", docker_gateway,
]
d.has_ssh = true
d.cmd = ["/sbin/init"]
# recommend separately build the image and tag as "vagrant-ubuntu:16.04"
#d.build_dir = "ubuntu"
# only passed through if you have environment variables set
#d.build_args = [
# "--build-arg", "http_proxy",
# "--build-arg", "https_proxy",
# "--build-arg", "no_proxy",
#]
end
config.landrush.enabled = true
config.landrush.tld = 'ncs.net'
config.landrush.host_redirect_dns = false
# use my host resolvconf dnsmasq instance, probably not be required
# for systems that can reach the google dns servers instead
config.landrush.upstream '127.0.0.1'
end
Dockerfile for image used
# taken from https://github.com/tknerr/vagrant-docker-baseimages/raw/master/ubuntu-1604/Dockerfile
# License MIT
FROM ubuntu:16.04
MAINTAINER Torben Knerr <mail@tknerr.de>
ENV DEBIAN_FRONTEND noninteractive
# ensure we have the en_US.UTF-8 locale available
RUN locale-gen en_US.UTF-8
# install common dependencies
RUN set -e \
&& apt-get update \
&& apt-get install -y \
curl \
dbus \
ifupdown \
iptables \
lsb-release \
openssh-server \
sudo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
;
# setup the vagrant user
RUN set -e \
&& if ! getent passwd vagrant; then useradd -d /home/vagrant -m -s /bin/bash vagrant; fi \
&& echo vagrant:vagrant | chpasswd \
&& echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& mkdir -p /etc/sudoers.d \
&& echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/vagrant \
&& chmod 0440 /etc/sudoers.d/vagrant \
;
# add the vagrant insecure public key
RUN set -e \
&& mkdir -p /home/vagrant/.ssh \
&& chmod 0700 /home/vagrant/.ssh \
&& curl -fSsL \
https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \
-o /home/vagrant/.ssh/authorized_keys \
&& chmod 0600 /home/vagrant/.ssh/authorized_keys \
&& chown -R vagrant /home/vagrant/.ssh \
;
# don't clean packages, we might be using vagrant-cachier
RUN rm /etc/apt/apt.conf.d/docker-clean
# run systemctl to simulate real machine
CMD ["/sbin/init"]
Commands run to test
# Assuming Dockerfile & Vagrantfile are in current directory
docker build -t vagrant-ubuntu:16.04 .
vagrant up
vagrant ssh
sudo apt-get update && sudo apt-get install -y dnsutils
dig test-landrush.ncs.net
@hferentschik any update on this?
@hferentschik ping?
Superseded by pull request #327 which adds an additional commit.
Docker provider works just needed hooks enabled.
71