Package: docker-shell
Docker Interactive Shell RunnerThedocker-shellcommand makes it quick and easy to start an interactive shell inside a Docker container, with the following features:Both Windows and Linux containers are supported.The current working directory is automatically bind-mounted into the container and set as the container's working directory.When running Linux containers under Linux host systems,host networking modeis enabled automatically to eliminate the need for exposing individual ports or port ranges.GPU support is automatically enabled when running GPU-enabled Linux containers under Linux host systems with the NVIDIA binary drivers and theNVIDIA Container Toolkitinstalled.Short aliases are provided for running popular shells:dbashforGNU Bashdshfor theBourne shelldzshforZshdcmdfor the Windows Command PromptdpsanddpowershellforWindows PowerShelldpwshforPowerShell CoreSee thedeveloper-imagesrepository for examples of container images designed specifically for use with docker-shell.ContentsRequirementsInstallationUsageBasic usagePassing additional flags to DockerWorking with alias tagsSpecifying additional options using image labelsSpecial variables available for use in labelsAutomatic Docker daemon selection under Windows 10LegalRequirementsOne of Docker's supported operating systems (with the additional minimum requirement of version 1809 or newer for Windows systems):Linux:64-bit version of one of Docker'ssupported Linux distributions(CentOS 7+, Debian 7.7+, Fedora 26+, Ubuntu 14.04+)macOS:macOS 10.10.3 Yosemite or newer running on 2010 or newer model Mac hardwareWindows 10:64-bit Windows 10 Pro/Enterprise/Education version 1809 or newer, or 64-bit Windows 10 Home version 2004 or newer withWSL2Windows Server:Windows Server 2019 / Windows Server version 1809 or newerAn appropriate Docker installation for your operating system:Docker Desktopunder Windows 10 or macOSDocker Community Edition (CE)under LinuxDocker Enterprise Edition (EE)under Windows ServerPythonversion 3.5 or newerInstallationTo installdocker-shell, run the following command:# This may need to be prefixed with sudo under Linux and macOSpip3installdocker-shellUsageBasic usageTo start a GNU Bash shell in anofficial Python containerunder Windows, macOS or Linux, run either of the following commands:# Long versiondocker-shellbashpython# Short versiondbashpythonTo start a Windows Command Prompt in aWindows Server Core containerunder Windows, run either of the following commands:# Long versiondocker-shellcmdmcr.microsoft.com/windows/servercore:ltsc2019# Short versiondcmdmcr.microsoft.com/windows/servercore:ltsc2019To start a PowerShell session in aWindows Server Core containerunder Windows, run any of the following commands:# Long versiondocker-shellpowershellmcr.microsoft.com/windows/servercore:ltsc2019# Short versionsdpsmcr.microsoft.com/windows/servercore:ltsc2019
dpowershellmcr.microsoft.com/windows/servercore:ltsc2019Passing additional flags to DockerAny additional flags that are specified on the command-line will be propagated automatically to the underlyingdocker runcommand:# The flags `-u 1000 --name mycontainer` will be passed directly to Dockerdocker-shellbashpython-u1000--namemycontainerWorking with alias tagsWhen working with lengthy image tags it is often more convenient to use thedocker tagcommand to create concise aliases, for example:# Add a shorter tag alias for the Windows Server Core imagedockertagmcr.microsoft.com/windows/servercore:ltsc2019windows:latest# Run a Windows Command Prompt using the short tagdcmdwindowsSpecifying additional options using image labelsIf there are bind mounts or command-line flags that you always use when running a particular image then you can specify these using image labels in your Dockerfile anddocker-shellwill apply them automatically:FROMmy-base-image# The directory specified by the environment variable `SOMEVAR` will be bind-mounted irrespective of the host platformLABELdocker-shell.mounts.1="\$SOMEVAR:/data"# The named volume specified by the special `VOLUME` variable (see below for details) will be bind-mounted irrespective of the host platformLABELdocker-shell.mounts.2="\$VOLUME:/project-data"# The current user's Desktop directory will be bind-mounted irrespective of the host platformLABELdocker-shell.mounts.3="~/Desktop:/desktop"# This specific user's Desktop directory will be bind-mounted only when running on Linux hostsLABELdocker-shell.linux.mounts.1="/home/user/Desktop:/user-desktop"# This specific user's Desktop directory will be bind-mounted only when running on macOS hostsLABELdocker-shell.mac.mounts.1="/Users/user/Desktop:/user-desktop"# This specific user's Desktop directory will be bind-mounted only when running on Windows hostsLABELdocker-shell.windows.mounts.1="C:/Users/User/Desktop:/user-desktop"# The command-line flags `-u 1000` will be applied irrespective of the host platformLABELdocker-shell.args.1="-u"LABELdocker-shell.args.2="1000"# The command-line flags `--priveleged` will be applied only when running on Linux hostsLABELdocker-shell.linux.args.1="--priveleged"# The command-line flags `-m 1GB` will be applied only when running on macOS hostsLABELdocker-shell.mac.args.1="-m"LABELdocker-shell.mac.args.2="1GB"# The command-line flags `-m 2GB` will be applied only when running on Windows hostsLABELdocker-shell.windows.args.1="-m"LABELdocker-shell.windows.args.2="2GB"Special variables available for use in labelsWhen specifying additional options via image labels, the following special variables are supported:CWD: resolves to the current working directory on the host systemHOSTIP: resolves to the IP address of the host system on the local network, or127.0.0.1if no network interfaces are availableVOLUME: resolves to the SHA-256 hash of the absolute path to the current working directory on the host system, suitable for use as a volume name when you want to associate data with a particular project but don't want to store files on the host filesystem for performance or compatibility reasonsAutomatic Docker daemon selection under Windows 10When running Docker Desktop under Windows 10, docker-shell can automatically switch between Windows containers mode and Linux containers mode based on the specified shell. (Windows containers mode is used forcmdandpowershell, whilst Linux containers mode is used for all other shells.) Because this behaviour alters system state and may be considered intrusive, it is disabled by default. To enable automatic daemon selection, set the environment variableDOCKERSHELL_WINDOWS_AUTO_SELECTto1.LegalCopyright © 2020, Adam Rehn. Licensed under the MIT License, see the fileLICENSEfor details.