-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·52 lines (44 loc) · 1.8 KB
/
docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
##############################################################################
# Filename: .../dotfiles/docker.sh #
# Purpose: File that manage docker #
# Authors: Giulio Coa <34110430+giulioc008@users.noreply.github.com> #
# License: This file is licensed under the LGPLv3. #
# Pre-requisites: #
# * docker #
# * sudo #
##############################################################################
if ! command -v sudo > /dev/null 2> /dev/null; then
echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${bold_red:-}sudo isn't installed${reset:-}" > /dev/stderr
exit 1
elif ! command -v docker > /dev/null 2> /dev/null; then
echo -e "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: ${bold_red:-}docker isn't installed${reset:-}" > /dev/stderr
exit 1
fi
# Remove all containers, images and volumes
docker-clean-all() {
local volume
sudo docker system prune --all --force --volumes
for volume in $(sudo docker volume ls \
| sed --regexp-extended --expression='s/\s+/,/g' \
| cut --delimiter ',' --fields 2); do
if [[ "${volume}" == 'VOLUME' ]]; then
continue
fi
sudo docker volume rm -f "${volume}" > /dev/null
done
}
# List all containers, images, networks and volumes
docker-list-all() {
sudo docker container ls --all
sudo docker image ls --all
sudo docker network ls
sudo docker volume ls
}
# Instantiate a Jupyter Docker Container
docker-jupyter() {
sudo docker run --rm --interactive \
--tty --name jupyter_01 \
--publish 8888:8888 \
jupyter/scipy-notebook:python-3.10
}