Skip to content

Instantly share code, notes, and snippets.

@icambron
Created July 17, 2014 03:43
Show Gist options
  • Save icambron/05bb58e9e268aff6bf5b to your computer and use it in GitHub Desktop.
Save icambron/05bb58e9e268aff6bf5b to your computer and use it in GitHub Desktop.
vagrant docker-run and env variables
#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'
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