Skip to main content

Docker Interactive Shell Runner

Project description

Docker Interactive Shell Runner

The docker-shell command 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 mode is 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 the NVIDIA Container Toolkit installed.

  • Short aliases are provided for running popular shells:

Contents

Installation

To install docker-shell, run the following command:

# This may need to be prefixed with sudo under Linux and macOS
pip3 install docker-shell

Usage

Basic usage

To start a GNU Bash shell in an official Python container under Windows, macOS or Linux, run either of the following commands:

# Long version
docker-shell bash python

# Short version
dbash python

To start a Windows Command Prompt in a Windows Server Core container under Windows, run either of the following commands:

# Long version
docker-shell cmd mcr.microsoft.com/windows/servercore:ltsc2019

# Short version
dcmd mcr.microsoft.com/windows/servercore:ltsc2019

To start a PowerShell session in a Windows Server Core container under Windows, run any of the following commands:

# Long version
docker-shell powershell mcr.microsoft.com/windows/servercore:ltsc2019

# Short versions
dps mcr.microsoft.com/windows/servercore:ltsc2019
dpowershell mcr.microsoft.com/windows/servercore:ltsc2019

Passing additional flags to Docker

Any additional flags that are specified on the command-line will be propagated automatically to the underlying docker run command:

# The flags `-u 1000 --name mycontainer` will be passed directly to Docker
docker-shell bash python -u 1000 --name mycontainer

Working with alias tags

When working with lengthy image tags it is often more convenient to use the docker tag command to create concise aliases, for example:

# Add a shorter tag alias for the Windows Server Core image
docker tag mcr.microsoft.com/windows/servercore:ltsc2019 windows:latest

# Run a Windows Command Prompt using the short tag
dcmd windows

Legal

Copyright © 2020, Adam Rehn. Licensed under the MIT License, see the file LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

docker_shell-0.0.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file docker_shell-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: docker_shell-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1

File hashes

Hashes for docker_shell-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7186160e9ede605ea781be4dcbb6d05ff2965bde5e113298f4efa7aaa6b3ebac
MD5 9f30e68ce2a6faec2ff6362cd235e607
BLAKE2b-256 000a1d0159fb537d3779712d84d5ef6825ece140d89bdd1e0e6b5191169a789b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page