Last active
August 29, 2015 14:08
-
-
Save jamiejackson/16f6ebde9447091fd403 to your computer and use it in GitHub Desktop.
Vagrant Docker Container Linking Issue
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 up --no-parallel | |
Bringing machine 'db' up with 'docker' provider... | |
Bringing machine 'web' up with 'docker' provider... | |
==> db: Vagrant has noticed that the synced folder definitions have changed. | |
==> db: With Docker, these synced folder changes won't take effect until you | |
==> db: destroy the container and recreate it. | |
==> db: Starting container... | |
==> db: Waiting for machine to boot. This may take a few minutes... | |
db: SSH address: 172.17.0.2:22 | |
db: SSH username: vagrant | |
db: SSH auth method: private key | |
==> db: Machine booted and ready! | |
==> db: Machine already provisioned. Run `vagrant provision` or use the `--provision` | |
==> db: to force provisioning. Provisioners marked to run always will still run. | |
==> web: Vagrant has noticed that the synced folder definitions have changed. | |
==> web: With Docker, these synced folder changes won't take effect until you | |
==> web: destroy the container and recreate it. | |
==> web: Starting container... | |
==> web: Waiting for machine to boot. This may take a few minutes... | |
web: SSH address: 172.17.0.3:22 | |
web: SSH username: vagrant | |
web: SSH auth method: private key | |
==> web: Machine booted and ready! | |
==> web: Machine already provisioned. Run `vagrant provision` or use the `--provision` | |
==> web: to force provisioning. Provisioners marked to run always will still run. | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/cbanbury $ vagrant docker-run web -- cat /etc/hosts | |
==> web: Creating the container... | |
web: Name: myproject_web_1414720818 | |
web: Image: cbanbury/centos-docker | |
web: Cmd: cat /etc/hosts | |
web: Volume: /home/jamie/apps/myproject/cfml/docs/incubation/railo/cbanbury:/vagrant | |
web: Link: myproject_db:db | |
web: | |
web: Container is starting. Output will stream in below... | |
web: | |
web: 172.17.0.4 cf59fcc31179 | |
web: ::1 localhost ip6-localhost ip6-loopback | |
web: fe00::0 ip6-localnet | |
web: ff00::0 ip6-mcastprefix | |
web: ff02::1 ip6-allnodes | |
web: ff02::2 ip6-allrouters | |
web: 127.0.0.1 localhost | |
web: 172.17.0.2 db | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/cbanbury $ vagrant ssh web | |
Last login: Thu Oct 30 14:12:05 2014 from 172.17.42.1 | |
[vagrant@46b8062eb587 ~]$ cat /etc/hosts | |
172.17.0.3 46b8062eb587 | |
ff00::0 ip6-mcastprefix | |
ff02::1 ip6-allnodes | |
ff02::2 ip6-allrouters | |
127.0.0.1 localhost | |
::1 localhost ip6-localhost ip6-loopback | |
fe00::0 ip6-localnet |
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 docker-run web -- cat /etc/hosts | |
==> web: Creating the container... | |
web: Name: myproject_web_1414678295 | |
web: Image: cbanbury/centos-docker | |
web: Cmd: cat /etc/hosts | |
web: Volume: /home/jamie/apps/myproject/cfml/docs/incubation/railo/cbanbury:/vagrant | |
web: Link: myproject_db:db | |
web: | |
web: Container is starting. Output will stream in below... | |
web: | |
web: 172.17.0.128 4d08af118d05 | |
web: ff02::1 ip6-allnodes | |
web: ff02::2 ip6-allrouters | |
web: 127.0.0.1 localhost | |
web: ::1 localhost ip6-localhost ip6-loopback | |
web: fe00::0 ip6-localnet | |
web: ff00::0 ip6-mcastprefix | |
web: 172.17.0.116 db | |
jamie@mintwork ~/apps/myproject/cfml/docs/incubation/railo/cbanbury $ vagrant ssh web | |
Last login: Thu Oct 30 14:10:02 2014 from 172.17.42.1 | |
[vagrant@46b8062eb587 ~]$ cat /etc/hosts | |
172.17.0.117 46b8062eb587 | |
127.0.0.1 localhost | |
::1 localhost ip6-localhost ip6-loopback | |
fe00::0 ip6-localnet | |
ff00::0 ip6-mcastprefix | |
ff02::1 ip6-allnodes | |
ff02::2 ip6-allrouters |
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 | |
# 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.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