GithubHelp home page GithubHelp logo

disisto / docker-exec-shortcut Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 51 KB

Make quick adjustments via Docker exec without having to type the entire docker exec -it CONTAINERNAME /bin/bash command into the CLI when needed.

License: MIT License

Shell 100.00%
alias aliases bash bash-script docker docker-exec docker-exec-command docker-executor zsh zsh-script

docker-exec-shortcut's Introduction

docker exec Shortcut

Make quick adjustments via Docker exec without having to type the entire docker exec -it CONTAINERNAME /bin/bash command into the CLI when needed.

Option 1: Get list

List all running containers and let select one of them. In this example 12 for Docker container named cdn.
./docker-selector.sh

Option 2: Direct call

Direct selection with the specification of the desired container. In this example cdn for Docker container named cdn.
./docker-selector.sh cdn

Optional: Bash/Zsh Alias

To connect to the container regardless of where you are in the CLI, you can also create an alias.

  1. Open your shell configuration file. Depending on the shell you're using, this might be ~/.bashrc, ~/.bash_profile, ~/.zshrc, or similar.

  2. Add the following line to the end of the file to create an alias for the dcon command:

alias dcon="/path/to/script/docker-selector.sh"

Replace dcon ("docker connect") with a command of your choice (e.g. dexec ("docker exec") or whatever you like).
Replace /path/to/script with the actual path to your script.

  1. Save the file and run the source command to load the updated alias settings into your current shell session:

source ~/.bashrc # or ~/.bash_profile, ~/.zshrc, depending on the file you edited

  1. Now, you can run the dcon command from anywhere to execute your script. For example:

dcon cdn

Example for Debian 12 (Bookwork)

sudo apt install curl nano

sudo curl -JLO https://github.com/disisto/docker-exec-shortcut/blob/main/docker-selector.sh

sudo chmod a+x docker-selector.sh

sudo nano sudo nano .bashrc

Add the line alias dcon="/home/username/docker-selector.sh" at the end of the file and save with the key combination "CTRL" + "X", "Y".

source ~/.bashrc

dcon

docker-exec-shortcut's People

Contributors

disisto avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.