dockerExec is a CLI tool written in Go that provides an enhanced alternative to docker exec -it <container_id> /bin/bash. It opens a bash session inside a specified Docker container with a customizable and user-friendly prompt.
Essentially transforming this:

If you have golang locally, you can install it via go:
go install github.com/ntavelis/dockerExec/cmd/dockerExec@latestDownload the latest binary from here, it contains a pre-compiled gzipped binary.
For instance for, VERSION=v1.0.0 and BINARY=dockerExec_Linux_x86_64
wget https://github.com/ntavelis/dockerExec/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\
tar xz && mv dockerExec /usr/bin/dockerExec && rm README.mdTo open a bash session inside a Docker container with the default prompt style:
dockerExec <containerID>You can customize the shell, user, prompt style, and prompt symbol using flags:
dockerExec --shell=/bin/bash --user=root --promptStyle="\\u@\\w:\\p" --promptSymbol="$" <containerID>- --shell: Specify the shell to use (default: /bin/bash)
- --user: Specify the user to run the shell as (default: current user)
- --promptStyle: Customize the prompt style (default: "π¨\\u ~> π\\w\r\n\\p")
- --promptSymbol: Customize the prompt symbol (default: ">")
- --help(-h): Display the help message
- --version(-v): Display version information
The --promptStyle flag allows you to customize the appearance of your bash prompt. The following placeholders are supported:
- \\u: Replaced with the current user
- \\w: Replaced with the current working directory
- \\p: Replaced with the prompt symbol (passed with the --promptSymbol flag)
Note: Special chars \n \r \t are supported currently and can be used to promptStyle flag
If you want your prompt to display the user and the working directory followed by the prompt symbol, you can set it like this:
dockerExec --promptStyle="\\u@\\w:\\p" <containerID>The --promptSymbol flag allows you to define a custom symbol to be used at the end of the prompt. This symbol will replace the \p placeholder in the --promptStyle flag.
dockerExec --promptSymbol="$" <containerID>The below commands will customize the prompt, you can add them as alias in your terminal to easily use custom prompt in docker containers.
dockerExec --promptStyle="\\u@\\w:\\p" --promptSymbol="\$" <containerID>dockerExec --promptStyle="\\w \\p" --promptSymbol=">" <containerID>dockerExec --promptStyle="π€\\u π»\\w π\\p" --promptSymbol=">" <containerID>dockerExec --promptStyle="\\u@\\w\n\r\\p" --promptSymbol="\$" <containerID>export container_name=$(docker inspect -f '{{.Name}}' cool_container | cut -c 2-)
export container_status=$(docker inspect -f '{{.State.Status}}' cool_container)
dockerExec --promptStyle="\\u@[$container_name ($container_status)]:\\w\n\r\\p" --promptSymbol=">" <containerID>




