Skip to content

Instantly share code, notes, and snippets.

@gogson
Last active October 3, 2023 15:17
Show Gist options
  • Select an option

  • Save gogson/0beaf571b2c97af46fe31aae1c9c44dc to your computer and use it in GitHub Desktop.

Select an option

Save gogson/0beaf571b2c97af46fe31aae1c9c44dc to your computer and use it in GitHub Desktop.
Open a bash to a running Docker container using a shell command

Purpose

Create a bash command for opening a shell to a running Docker container

Usage

Fetch container ID from docker ps and run docker-bash 880e6a9d9601 where "880e6a9d9601" is the container ID

Install

Put the function in your .bashrc or .profile file.

docker-bash() {
sudo docker exec -i -t $1 /bin/bash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment