Created
November 28, 2023 16:37
-
-
Save glaucomunsberg/aafcb9eb0500144fdad1cfa2ba4d2640 to your computer and use it in GitHub Desktop.
bash_profile with alias to docker compose commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# past content bellow and and reload source | |
# $ nano ~/.bash_profile | |
# $ source ~/.bash_profile | |
# Command '$ dcu container_name' alias to '$ docker compose up -d container_name' | |
# Command '$ dcs container_name' alias to '$ docker compose stop container_name' | |
execute_dcs() { | |
if [ -z "$1" ]; then | |
echo "Usage: dcs <container_name>" | |
return 1 | |
fi | |
local container_name="$1" | |
# Check if Docker Compose is installed | |
if ! command -v docker compose > /dev/null 2>&1; then | |
echo "Docker Compose is not installed. Please install it first." | |
return 1 | |
fi | |
# Stop the specified container using Docker Compose | |
if [ -n "$1" ]; then | |
docker compose stop "$container_name" | |
return 1 | |
else | |
docker compose down | |
return 1 | |
fi | |
} | |
execute_dcu() { | |
if [ -z "$1" ]; then | |
echo "Usage: dcs <container_name>" | |
return 1 | |
fi | |
local container_name="$1" | |
# Check if Docker Compose is installed | |
if ! command -v docker compose > /dev/null 2>&1; then | |
echo "Docker Compose is not installed. Please install it first." | |
return 1 | |
fi | |
# Stop the specified container using Docker Compose | |
if [ -n "$1" ]; then | |
docker compose up -d "$container_name" | |
return 1 | |
else | |
docker-compose up -d | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment