Set Docker Container Command Aliases
Manually entering Docker containers with long commands like:
docker exec -it wuwei-nginx bash
…can quickly become tedious. To streamline your workflow, you can define aliases for commonly accessed containers.
Edit Your .bashrc File
Open your .bashrc
file in a text editor:
nano ~/.bashrc
Add the following alias definitions at the bottom:
alias docker_nginx="docker exec -it wuwei-nginx /bin/bash"
alias docker_php="docker exec -it wuwei-php /bin/bash"
alias docker_mysql="docker exec -it wuwei-mysql /bin/bash"
alias docker_redis="docker exec -it wuwei-redis /bin/bash"
alias docker_xunsearch="docker exec -it wuwei-xunsearch /bin/bash"
alias docker_zlmediakit="docker exec -it wuwei-zlmediakit /bin/bash"
Apply Changes
Run the following command to reload your shell configuration:
source ~/.bashrc
Usage
You can now enter containers using simple commands like:
docker_nginx # Enters the Nginx container
docker_php # Enters the PHP container
docker_mysql # Enters the MySQL container
These aliases save time and reduce typing errors when managing your WuWei Docker environment.