Package: docker-inside
Docker Insidedockerinsideis a Python (Python3 only) package that shall simplify running docker images as the current user
similar to the wayJenkinsawesomedocker.inside()works.
There are two main use-cases:You want to easily share access between a container and your environment without having to
manually modify the user id and group id of the files created by the running container.You want to rundockerizedGUI applications but share your home environmentYou don't have to write a Dockerfile just to adapt to your environment (user id / group id). It is
a much more elegant approach to adapt the environment during startup of the container on the fly asJenkinsdoes it.InstallationPrerequisits:Python3 installation (>= 3.6)python3-venvis recommended to create a virtual environmentInstall currentstableversion (preferably in a virtual environment):pip install git+https://github.com/boon-code/docker-inside.gitFor convenience,dockerinsideusessu-execwhich is
statically compiled usingalpineandmusl-clibrary. To build it, you have to run# use --auto-pull to download alpine image for compilation if it's not available
    docker-inside-setup --auto-pullThis will create a directory~/.config/docker_inside/and put a file namedsu-execthere. You
can also compilesu-execand create the file structure yourself or not use it at all. If this
file doesn't exist,suis used to switch user id which might cause problems withttyhandling,
so it's highly recommended to usesu-exec.Big thanks toNatanael Copa(ncopa) for sharingsu-exec.NO_READMEIf you experience problems related to packaging theREADME.mdor related tosetuptoolsyou can disable this behavior using the environment variableNO_README(f.e.NO_README=1).UsageBasicRunning anubuntu:16.04container as current user with the home directory mounted:docker-inside -H ubuntu:16.04which is roughly equivalent to runningdocker run --rm -ti --user "$(id -u)" -v "${HOME}:${HOME}" ubuntu:16.04but does already add users and groups so you won't seeI have no name!in your shell prompt.Fake HomeYou can also use afakehome directorymkdir -p /tmp/fake-home
    docker-inside --mount-as-home /tmp/fake-home ubuntu:16.04 -- echo "Hello, World" \>~/readme.txt
    #DockerInside : MainThread : INFO : Starting container: 59133ebeb3a3116999f66b4e302ba675a74f02ac83ae526704f2f4cdbd82ed5d
    #DockerInside : MainThread : INFO : Container 59133ebeb3a3116999f66b4e302ba675a74f02ac83ae526704f2f4cdbd82ed5d stopped
    cat /tmp/fake-home/readme.txt
    #Hello, WorldJenkins DebuggingSometimes, I just quickly want to debug a problem on a failingJenkinsjob which uses docker with
lot's of bind mounts which is as simple as this:cd <WORKSPACE>
    docker-inside -v <first-mount>:<some-path> \
                  -v <second-mount>:<some-other-path> \
                  -v <WORKSPACE> \
                  -w <WORKSPACE> \
                  <IMAGE_TO_USE> \
                  [optional-command]Additional Use-CasesPlease let me know I you need support for more options from originaldocker runcommand or have
any other suggestions how to improve this package.
Please also let me know if your Docker image is failing using this package and I will see if I can
fix the issue. Adding users and groups is unfortunately quite different among distributions.RelatedI still use the package myself on a regular basis when using Docker. However, to avoid having to
rely on work-arounds used in this script,podmanis a simple and powerful replacement for Docker.podmanhandles user permissions and bind mounts in a sane way per default. Check it out!