Set correct env variables for `docker exec` commands

Fix #9155, #9044 

This depends on https://github.com/docker/libcontainer/pull/264 to set correct environment variables for exec session and should be rebased when it's merged.
oops :poop: . Fixed in 2a60624