Skip to content

Commit 0a5d4a7

Browse files
authored
Update .docker.sh
fixed minor issues
1 parent 5d1ff20 commit 0a5d4a7

1 file changed

Lines changed: 3 additions & 86 deletions

File tree

.docker.sh

Lines changed: 3 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ unset dockerDB
55
readarray -t dockerDB< <(for x in $(docker ps --format '{{.Names}}'); do docker inspect ${x} | jq -r '.[0]|"\(.Config.Labels["com.docker.compose.project"]):\(.Config.Labels["com.docker.compose.project.working_dir"]):\(.Config.Labels["com.docker.compose.service"])"'; done)
66
}
77
function GREPDOCKERCOMPOSE () {
8+
read -p "Type Path to search in": gdir
89
read -p "Type string to search for": STRING
910
read -p "Would you like to Find all docker-compose files without this string? Y/N": INVERT
1011
case "${INVERT^}" in
11-
Y|y ) grep -irlv "${STRING}" /home/meir/dockerfiles/*/docker-compose.yml ;;
12-
N|n ) grep -irl "${STRING}" /home/meir/dockerfiles/*/docker-compose.yml ;;
12+
Y|y ) grep -irlv "${STRING}" ${gdir}/*/docker-compose.yml ;;
13+
N|n ) grep -irl "${STRING}" ${gdir}/*/docker-compose.yml ;;
1314
* ) echo "Wrong selection" ;;
1415
esac
1516
}
@@ -31,36 +32,6 @@ docker-compose -f ${DIR}/docker-compose.yml up -d;
3132
done
3233
}
3334

34-
: << 'EOF'
35-
function WEBAPPS () {
36-
YAMLFILES=$(find /home/meir/dockerfiles -maxdepth 2 -type f -iname "docker-compose.yml" 2>/dev/null)
37-
for X in ${YAMLFILES}; do
38-
YMLFILE=${X##*/}
39-
FULLDIR=${X%/*}
40-
CONTNAME=${FULLDIR##*/}
41-
EOF
42-
43-
: << 'EOF'
44-
function DOCKER_RUNNING_CONTS_AUTOSTART () {
45-
echo -e "1 - All currently running containers will be restarted unless stopped"
46-
read -p "Please make your selection": SELECT
47-
if [[ "${SELECT}" == "1" ]]; then docker update --restart unless-stopped $(docker ps -q); fi
48-
}
49-
EOF
50-
51-
: << 'EOF'
52-
function DOCKERRMI () {
53-
STRING=${1}
54-
STRING=${STRING:?"Usage: $0 <String to search for images>"; return;}
55-
TBDEL=$(docker images | grep -i "$STRING")
56-
JUSTIMG=$(docker images | grep "$STRING" | awk '{print $3}')
57-
printf '%s\n' "${TBDEL}"
58-
read -p "Delete these images above? (Yy/Nn)": GO
59-
if [[ "${GO^^}" == Y ]]; then
60-
printf '%s\n' "${TBDEL}" | while read -r name; do docker rmi "$name"; done
61-
fi
62-
}
63-
EOF
6435

6536
function DOCKERPORTSUSED () {
6637
ALLPORTS=$(docker container ls --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" -a)
@@ -70,62 +41,8 @@ function DOCKERPORTSUSED () {
7041

7142

7243
alias dockerports='docker container ls --format "table {{.Ports}}" | cut -d ">" -f1 | tr -d :-'
73-
###alias dockerps="docker ps | awk {'print $1,$NF'}"
74-
###alias DOCKERSTOPALL="docker stop $(docker container list -q -a)"
75-
###alias DOCKERSTARTALL="docker start $(docker ps -a -q -f status=exited)"
76-
###alias DOCKERRESTARTALL="docker restart $(docker ps -a -q)"
7744
alias dockerstopall='for X in $(docker ps -q); do docker stop ${X}; done'
78-
79-
: << 'EOF'
80-
function D-C () {
81-
docker-compose -f ~/dockerfiles/$1 pull
82-
docker-compose -f ~/dockerfiles/$1 up -d
83-
docker logs -f $1
84-
}
85-
EOF
86-
: << 'EOF'
87-
function D-C () {
88-
docker-compose -f ~/dockerfiles/$1 pull
89-
docker-compose -f ~/dockerfiles/$1 up -d
90-
docker logs -f $1
91-
}
92-
EOF
93-
94-
: << 'EOF'
95-
function docker-compose () {
96-
PARAM="${@}"
97-
FPARAM="${1}"
98-
if [[ "${FPARAM}" -eq "up" ]]; then
99-
docker-compose ${PARAM} --remove-orphans
100-
docker system prune -fa
101-
docker volume prune -f
102-
fi
103-
}
104-
EOF
105-
106-
107-
function DOCKERPORTSUSED () {
108-
ALLPORTS=$(docker container ls --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" -a)
109-
readarray -t PORTSINUSE< <(echo "${ALLPORTS}" | awk '{for(i=1;i<=NF;i++){if($i~/^:/){print $i}}}' | cut -d '>' -f1 | tr -d :-)
110-
printf "%s\n" ${PORTSINUSE[@]}
111-
}
112-
113-
11445
alias dockerports='docker container ls --format "table {{.Ports}}" | cut -d ">" -f1 | tr -d :-'
115-
116-
: << 'EOF'
117-
PORTSUSED=$(grep -i -A7 "ports:" ${X} | grep -E '.*[1-9][0-9].*:[1-9][0-9]' | cut -d ':' -f1 | xargs)
118-
CONTNAME=$(grep -w "container_name:" ${X} | cut -d ":" -f2 | xargs)
119-
ISRUNNING=$(docker ps | awk '{print $2}' | grep -ic "${CONTNAME}")
120-
121-
for port in "${PORTSUSED}"; do OPENPORTS+=$(netstat -tulpen 2>/dev/null | awk '{print $1,$4}' | grep "${port}"); done
122-
123-
echo -e "\n\n############ Container - ${CONTNAME}\nLISTENS ON - ${PORTSUSED}\nIS RUNNING = ${ISRUNNING}\nOPEN PORTS = ${OPENPORTS[@]}"
124-
unset OPENPORTS PORTSUSED CONTNAME ISRUNNING
125-
done
126-
}
127-
EOF
128-
12946
alias dockernames="docker ps --format '{{.Names}}'"
13047
alias dockershowallinfo='docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Mounts}}\t{{.Ports}}\t{{.Networks}}\t{{.State}}" | tr -s " " | column'
13148
alias dstopall="docker stop $(docker container list -q -a)"

0 commit comments

Comments
 (0)