Created
July 17, 2014 03:43
-
-
Save icambron/05bb58e9e268aff6bf5b to your computer and use it in GitHub Desktop.
vagrant docker-run and env variables
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
#confirms env variable is set in container | |
vagrant docker-run -- sh -c 'exec env | grep DB_PORT_5432_TCP_PORT' | |
#can't echo env variable because evaluated on VM host | |
vagrant docker-run -- sh -c 'echo $DB_PORT_5432_TCP_PORT' | |
#can't connect to psql because of that | |
vagrant docker-run db -- sh -c 'exec psql -h $DB_PORT_5432_TCP_ADDR -p $DB_PORT_5432_TCP_PORT -U postgres' |
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
Vagrant.configure("2") do |config| | |
config.vm.define "db" do |db| | |
db.vm.provider "docker" do |d| | |
d.image = "library/postgres" | |
d.link 'db:db' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment