Skip to content

Instantly share code, notes, and snippets.

@sunnycmf
Forked from jmeyo/beaudev_docker_aliases.sh
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnycmf/4b9b88ce499ae0dba757 to your computer and use it in GitHub Desktop.
Save sunnycmf/4b9b88ce499ae0dba757 to your computer and use it in GitHub Desktop.
Beaudev Docker alias and usefull functions
#!/bin/bash
# Get id, name and ip adresses of all active docker container
function do_get_ip_address() {
paste <(sudo docker ps | tail -n +2 | awk {'printf "%s\t%s\n", $1, $2 '}) <(sudo docker ps -q | xargs sudo docker inspect | tail -n +2 | grep \"IPAddress\" | awk '{ print $2 }' | tr -d ',"')
}
# stop and remove a container based on his id
function do_stop_rm_container() {
[ -z "$1" ] && echo "Give me a container ID" && return
container_name=$1
sudo docker stop $container_name && sleep 2 && sudo docker rm $container_name && echo "container $container_name stopped and removed"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment