Skip to content

Instantly share code, notes, and snippets.

@jmeyo
Last active December 31, 2017 00:03
Show Gist options
  • Save jmeyo/fface4f606ae6bf5365c to your computer and use it in GitHub Desktop.
Save jmeyo/fface4f606ae6bf5365c 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