From 8f015bb3cba40f3065ea5e9c9283e9e54a2c0175 Mon Sep 17 00:00:00 2001 From: Matt P Date: Mon, 25 Nov 2024 11:16:25 +1000 Subject: [PATCH] Update .bashrc minor updates --- .bashrc | 77 +++++++++++++++++++-------------------------------------- 1 file changed, 26 insertions(+), 51 deletions(-) diff --git a/.bashrc b/.bashrc index e1662cc..fd91015 100644 --- a/.bashrc +++ b/.bashrc @@ -1,71 +1,48 @@ -# nano ~/.bashrc -# run 'source ~/.bashrc' to load latest changes in current session - -# ALIASES ##################################################### -# Note that these aliases do not work on Synology docker, due to the fact that they are a number of versions behind. (change "docker compose" to "docker-compose" and then it should work) +################################################################## +# run 'source ~/.bashrc' to load latest changes in current session -########## Set docker aliases -# +# ALIASES ######################################################## +# Note that these aliases do not work on Synology docker, due to the fact that they are a number of versions behind. (c> -# basic change folder command -alias cdkr='cd ~/docker' +# Set docker aliases +alias dive='docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive' +alias cdkr='cd ~/docker' alias cdcd='cd ~/code/dockerholics/compose-examples' - -# list all containers in a formatted list -alias list='docker ps -a --format "table {{.Names}}\t{{.ID}}\t{{.Image}}\t{{.Status}}" | (read -r; printf "%s\n" "$REPLY"; sort -k 1 )' - -# stop and remove all containers in your compose file. Optional to add a single container name +alias list='docker ps -a --format "table {{.Names}}\t{{.ID}}\t{{.Status}}" | (read -r; printf "%s\n" "$REPLY"; sort -k > alias down='docker compose down -v' - -# pull latest images in your compose file. Optional to add a single container name alias pull='docker compose pull' - -# start all containers in your compose file. Optional to add a single container name alias up='docker compose up -d' - -# inspect the details for a given container alias inspect='docker inspect' - -# create, but dont start, all containers in your compose file. Optional to add a single container name alias create='docker compose up --no-start' - -# stop a specific container alias stop='docker stop' - -# stop all containers -alias stopall='docker stop $(docker ps -a -q)' - -# start all containers alias startall='docker start $(docker ps -a -q)' - -# start a specific container +alias stopall='docker stop $(docker ps -a -q)' alias start='docker start' - -# Remove all images and volumes that are not in use. *including stopped containers* alias prune='docker system prune -a --volumes' - -# delete a stopped container alias del='docker rm' - -# restart a container -alias cycle='docker restart' - -# show the logs for a specific container alias logs='docker logs -f' - -# show host disk use for docker alias ddf='docker system df' -# rename a specified container -alias rename='docker rename' +# Set other aliases +alias ver='cat /etc/os-release && uname -mrs && docker -v && docker compose version' +alias osupgrade='sudo do-release-upgrade' +alias upgrade='sudo apt-get update && sudo apt-get upgrade -y && sudo apt autoremove --purge -y' +alias topsize='sudo du -Sha | sort -rh | head -n 10' + + # FUNCTIONS #################################################### -# -# run a command inside a given container. Pass a single command or encapsulate in "" for a command with a parameter +# run a command inside a given container drun() { - docker exec $1 + docker exec $1 $2 +} + +# Restarts a container +# +cycle() { + docker restart $1 } # pulls a image and then creates and starts it @@ -99,10 +76,8 @@ piu() { sudo netstat -plan | grep ":$1" } - - # ENVIRONMENT SETTINGS ########################################## +# # Helps avoid timeouts for large yaml scripts - export DOCKER_CLIENT_TIMEOUT=360 -export COMPOSE_HTTP_TIMEOUT=360 \ No newline at end of file +export COMPOSE_HTTP_TIMEOUT=360