A collection of Vagrant-friendly docker base images + corresponding Vagrant baseboxes. Something inbetween the official distro base image and puhsion/baseimage, just enough to make it work with Vagrant.
On top of the official distro base image it includes:
- the
vagrant
user (passwordvagrant
) with passwordless sudo enabled - the vagrant insecure public key in
~/.ssh/authorized_keys
sshd
running in the foreground
The intended use of the Vagrant-friendly docker base images is to use them as a basebox in your Vagrantfile
. These baseboxes simply reference one of the actual docker base images below.
The following baseboxes are currently published on Atlas:
Use the config.vm.box
setting to specify the basebox in your Vagrantfile.
For example, run vagrant init tknerr/baseimage-ubuntu-16.04 --minimal
to create the Vagrantfile below:
Vagrant.configure(2) do |config|
config.vm.box = "tknerr/baseimage-ubuntu-16.04"
end
Then, running vagrant up --provider docker
should look similar to this:
W:\repo\sample>vagrant up --provider=docker
Bringing machine 'default' up with 'docker' provider...
==> default: Creating the container...
default: Name: minimal_default_1441605508
default: Image: tknerr/baseimage-ubuntu:16.04
default: Volume: /w/repo/sample:/vagrant
default: Port: 0.0.0.0:2222:22
default:
default: Container created: f366398390f6b33f
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 192.168.59.104:2222
default: SSH username: vagrant
default: SSH auth method: private key
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!
Please note: until version 1.7.2 of Vagrant the docker provisioner does not inspect the packaged Vagrantfile in the basebox, i.e. it might fail with an error like that:
$ vagrant up --provider docker Bringing machine 'default' up with 'docker' provider... There are errors in the configuration of this machine. Please fix the following errors and try again: docker provider: * One of "build_dir" or "image" must be set
As a workaround you have to import the desired basebox once, so it is available locally and the docker provider can inspect the Vagrantfile we package into the box:
$ vagrant box add tknerr/baseimage-ubuntu-16.04
After that, you can use the
config.vm.box
with the docker baseimage as expected.
In case you want to work with the actual docker base images directly, the following ones (see subdirectories) are available on docker hub:
You can use it in your Vagrantfile in it's most simple form like this and then
run vagrant up
:
Vagrant.configure(2) do |config|
config.vm.provider "docker" do |d|
d.image = "tknerr/baseimage-ubuntu:16.04"
end
end
If you want to use provisioners, you need to additionally tell vagrant that this container has ssh enabled:
Vagrant.configure(2) do |config|
config.vm.provider "docker" do |d|
d.image = "tknerr/baseimage-ubuntu:16.04"
d.has_ssh = true
end
# use shell and other provisioners as usual
config.vm.provision "shell", inline: "echo 'hello docker!'"
end
How to contribute?
- fork this repo
- create a new branch with your changes
- submit a pull request
MIT - see the accompanying LICENSE file