Created
October 24, 2014 17:53
-
-
Save jamiejackson/e8f77e4fa90a9ff343f8 to your computer and use it in GitHub Desktop.
Trying to Make Vagrant-Friendly Docker Container from Centos 6.5 Docker Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos:centos6 | |
RUN yum -y update | |
RUN yum install -y openssh-server wget systemd-sysv | |
RUN useradd -c "vagrant" -d /home/vagrant -m -s /bin/bash vagrant | |
RUN echo 'root:vagrant' | chpasswd | |
RUN echo 'vagrant:vagrant' | chpasswd | |
RUN mkdir -p /root/.ssh/ /home/vagrant/.ssh/ | |
RUN wget --no-check-certificate https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant -O /root/.ssh/id_rsa | |
RUN wget --no-check-certificate https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /root/.ssh/id_rsa.pub | |
RUN wget --no-check-certificate https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant -O /home/vagrant/.ssh/id_rsa | |
RUN wget --no-check-certificate https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/id_rsa.pub | |
RUN chmod 600 /home/vagrant/.ssh/id* | |
RUN chmod 600 /root/.ssh/id* | |
RUN cp /root/.ssh/id_rsa /etc/ssh/ssh_host_key | |
RUN cp /root/.ssh/id_rsa /etc/ssh/ssh_host_rsa_key | |
RUN cp /root/.ssh/id_rsa /etc/ssh/ssh_host_ecdsa_key | |
RUN chmod 600 /root/.ssh/id* | |
RUN echo "Created /shared" | |
EXPOSE 22 | |
CMD /usr/sbin/sshd -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/separates $ vagrant up | |
Bringing machine 'myproject_db' up with 'docker' provider... | |
==> myproject_db: Building the container from a Dockerfile... | |
myproject_db: Image: c2720c0f819c | |
==> myproject_db: Fixed port collision for 22 => 2222. Now on port 2200. | |
==> myproject_db: Creating the container... | |
myproject_db: Name: separates_myproject_db_1414172864 | |
myproject_db: Image: c2720c0f819c | |
myproject_db: Volume: /home/jamie/apps/myproject/cfml/docs/incubation/railo/separates:/vagrant | |
myproject_db: Port: 2200:22 | |
myproject_db: | |
myproject_db: Container created: 43d1f10bc500e99a | |
==> myproject_db: Starting container... | |
==> myproject_db: Waiting for machine to boot. This may take a few minutes... | |
myproject_db: SSH address: 172.17.0.47:22 | |
myproject_db: SSH username: vagrant | |
myproject_db: SSH auth method: private key | |
myproject_db: Warning: Authentication failure. Retrying... | |
myproject_db: Warning: Authentication failure. Retrying... | |
^C==> myproject_db: Waiting for cleanup before exiting... | |
^[[AVagrant exited after cleanup due to external interrupt. | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/separates $ vagrant up | |
Bringing machine 'myproject_db' up with 'docker' provider... | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/separates $ | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/separates $ vagrant ssh | |
vagrant@172.17.0.47's password: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker' | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
unless Vagrant.has_plugin?("vagrant-triggers") | |
raise 'vagrant-triggers plugin needs to be installed: vagrant plugin install vagrant-triggers' | |
end | |
config.vm.define "myproject_db" do |v| | |
v.vm.provider "docker" do |d| | |
d.build_dir = "./myproject_db" | |
d.has_ssh = true | |
d.remains_running = true | |
end | |
end | |
# config.vm.provision "docker" do |d| | |
# # The following line terminates all ssh connections. Therefore | |
# # Vagrant will be forced to reconnect. | |
# # That's a workaround to have the docker command in the PATH | |
# config.vm.provision "shell", inline: | |
# "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill" | |
# end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source blog post: http://blog.gluster.org/2014/08/building-vagrant-friendly-docker-containers-on-centos/