I have what I'm sure is a dumb problem, and likely betrays some 
misunderstanding about Vagrant, Docker, shells, or possibly all three. But 
here goes: I'm running Vagrant with a Docker provider, using the default 
boot2docker host VM. What I'm trying to do is run some commands, but the 
problem is that my shell variables are being interpreted in the host VM's 
environment instead of the container's. To demonstrate:

-> vagrant docker-run db -- whoami
==> db: Docker host is required. One will be created if necessary...
--SNIP--
     db: root

That's correct; my Postgres container runs as root. But:

-> vagrant docker-run db -- sh -c 'echo $(whoami)'
==> db: Docker host is required. One will be created if necessary...
--SNIP--
    db: docker

Which is silly. It looks like the $(whoami) is being evaluated by the host 
VM, where the user is named docker. That example is contrived, but the 
underlying problem keeps me from accessing environment variables that do 
matter:

-> vagrant docker-run db -- sh -c 'exec psql -h "$DB_PORT_5432_TCP_ADDR" -p 
"$DB_PORT_5432_TCP_PORT" -U postgres'

Which doesn't work because (as I understand it) those vars are getting 
evaluated to nothing in the host, which of course has no idea what port I 
have PG set up on.

Any ideas on how to fix this? Perhaps there's some extra level of 
indirection I need to put into the command itself, or maybe I'm just 
missing something.

Thanks,
Isaac

-- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to