Created
October 31, 2014 17:46
-
-
Save jamiejackson/cbfa524ac334312f2f24 to your computer and use it in GitHub Desktop.
Vagrant Hostname Problems in Docker Provider
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/cbanbury $ vagrant ssh db | |
Last login: Thu Oct 30 03:23:32 2014 from 172.17.42.1 | |
[vagrant@d328e74ec650 ~]$ hostname | |
d328e74ec650 | |
[vagrant@d328e74ec650 ~]$ exit | |
logout | |
Connection to 172.17.0.52 closed. | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/cbanbury $ vagrant docker-run db -- hostname | |
==> db: Creating the container... | |
db: Name: myproject-db_1414776867 | |
db: Image: cbanbury/centos-docker | |
db: Cmd: hostname | |
db: Volume: /home/jamie/apps/myproject/cfml/docs/incubation/railo/cbanbury:/vagrant | |
db: | |
db: Container is starting. Output will stream in below... | |
db: | |
db: myproject-db |
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 | |
vm_temp_dir = "/vagrant/temp" | |
host_temp_dir = "./temp" | |
host_script_dir = "./scripts" | |
vm_script_dir = "/vagrant/scripts" | |
host_provisioned_dir = "#{host_temp_dir}/provisioned" | |
vm_provisioned_dir = "#{vm_temp_dir}/provisioned" | |
password = "mypassword" | |
config.vm.define "db" do |v| | |
host_db_script_dir = "#{host_script_dir}/db" | |
vm_db_script_dir = "#{vm_script_dir}/db" | |
v.vm.provider "docker" do |d| | |
#d.build_dir = "./myproject_db" | |
d.name = "myproject-db" | |
d.image = "cbanbury/centos-docker" | |
d.has_ssh = true | |
d.remains_running = true | |
d.ports = ["3306:3306"] | |
d.cmd = ["#{vm_db_script_dir}/start.sh"] | |
end | |
v.vm.hostname = "myproject-db" | |
# DNS isn't working without this, because Google's nameservers (e.g., 8.8.8.8) aren't working, for some reason | |
# TODO: fix this hack? | |
# v.vm.provision "shell", inline: "printf \"nameserver 172.25.101.250\nnameserver 8.8.8.8\" > /etc/resolv.conf" | |
v.vm.provision :shell, :path => "#{host_script_dir}/cbanbury_centos_vagrant_set_passwords.sh", :args => [] | |
v.vm.provision :shell, :path => "#{host_script_dir}/yum_localize_cache_dir.sh", :args => [] | |
# Install MariaDB | |
v.vm.provision :shell, :path => "#{host_db_script_dir}/db_install_mariadb.sh", :args => [ | |
"--conf-file-to-patch=/etc/my.cnf.d/server.cnf", | |
"--password=#{password}", | |
"--patch-file=#{vm_db_script_dir}/db_mariadb_rhel65_server.cnf.patch", | |
"--provisioned-dir=#{vm_provisioned_dir}" | |
] | |
end | |
config.vm.define "web" do |v| | |
host_web_script_dir = "#{host_script_dir}/web" | |
vm_web_script_dir = "#{vm_script_dir}/web" | |
v.vm.provider "docker" do |d| | |
d.name = "myproject-web" | |
d.image = "cbanbury/centos-docker" | |
d.has_ssh = true | |
d.remains_running = true | |
d.ports = ["80:80"] | |
d.link("myproject_db:db") | |
end | |
v.vm.hostname = "myproject-db" | |
v.vm.provision :shell, :path => "#{host_script_dir}/cbanbury_centos_vagrant_set_passwords.sh", :args => [] | |
v.vm.provision :shell, :path => "#{host_script_dir}/yum_localize_cache_dir.sh", :args => [] | |
end | |
# config.vm.provision "docker" do |d| | |
# d.pull_images "cbanbury/centos-docker" | |
# end | |
config.trigger.after :destroy, :stdout => true, :force => true do | |
info "Removing provisioned directory contents: #{host_provisioned_dir}/*" | |
FileUtils.rm_rf Dir.glob("#{host_provisioned_dir}/*") | |
#info "Removing WEB-INF from working copy." | |
#FileUtils.rm_rf("#{host_wwwroot}/WEB-INF") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment