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.
you have 2 vars passed and 3 `%q`'s