(1) Docker containers are plenty of isolation themselves. In your Dockerfile, don’t bother creating a virtual environment, just pip install
packages into the “global” space (on an Ubuntu base you’ll see files in `/usr/local/lib/python2.7/dist-packages’).
(2) Or, this is a fine use case for an entrypoint script:
#!/bin/sh
. /root/.env/api/bin/activate
p-api config
exec "$@"
Also note that the activate
script is strictly optional, and you could instead
#!/bin/sh
/root/.env/api/bin/p-api config
exec "$@"
and not change the $PATH
for the main container execution.