Last active
July 22, 2019 14:15
-
-
Save andyj/2b7fe396fbe669f2bf3681eba8b6dcd6 to your computer and use it in GitHub Desktop.
Essential Docker commands for .bash_profiles wrapped up as terminal functions
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
MY_IP=127.0.0.1 | |
#Ubuntu | |
#MY_IP=$(wget -qO- icanhazip.com) | |
#MAC | |
#MY_IP=$(ifconfig en0 | grep "inet 1" | awk '/inet/ { print $2 } ') | |
echo Current IP: $MY_IP | |
# Stop all running containers | |
dstopall(){ | |
docker stop $(docker ps -aq) | |
} | |
# Remove all containers | |
dremovec(){ | |
dstopall | |
docker rm $(docker ps -aq) | |
} | |
# Remove all images | |
dremovei(){ | |
dstopall | |
docker rmi $(docker images -q) | |
} | |
dbuild() { | |
source ~/.bash_profile | |
IPADDRESS="$MY_IP" docker-compose up --build --abort-on-container-exit | |
} | |
dbuildclean() { | |
source ~/.bash_profile | |
IPADDRESS="$MY_IP" docker-compose down | |
dremovei | |
dremovei | |
IPADDRESS=$MY_IP docker-compose up --force-recreate --build --abort-on-container-exit | |
} | |
dockerpurge(){ | |
docker stop $(docker ps -aq) | |
docker rm $(docker ps -aq) | |
docker rmi $(docker images -q) | |
} | |
dockerrebuild(){ | |
IPADDRESS="$MY_IP" docker-compose up --build --remove-orphans --force-recreate | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment