# docker compose helper scripts

[![pknw1logo-white.png](https://bookstack.notflix.pknw1.co.uk/uploads/images/gallery/2025-01/scaled-1680-/HLPpknw1logo-white-png.png)](https://bookstack.notflix.pknw1.co.uk/uploads/images/gallery/2025-01/scaled-1680-/HLPpknw1logo-white-png.png)

##### `<span class="editor-theme-code">/usr/local/bin/uplog</span>`

<u>****Helper Scripts****</u>

The docker helper scripts are to allow more rapid access to frequent requests

- [ ] <span style="white-space: pre-wrap;">create </span>`<span class="editor-theme-code">/usr/local/bin/uplog</span>`
- [ ] <span style="white-space: pre-wrap;">chmod +x </span>`<span class="editor-theme-code">/usr/local/bin/uplog</span>`

```
#!/bin/bash
# /usr/local/bin/uplog

if [[ $# -eq 0 ]]
then
  docker compose up -d && docker compose logs -f
else
  docker compose -f $1.yml up -d && docker compose -f $1.yml logs -f
fi
```

- [ ] update profile aliases
- [ ] <span style="white-space: pre-wrap;">vi </span>`<span class="editor-theme-code">~/.bash_aliases</span>`
- [ ] logout and back in

```
# additional bash_alias entries for docker management

alias down='docker compose down'
alias up='docker compose up -d'
alias logs='docker compose logs -f'
```

```

```

<details id="bkmrk-script-infocheck-mar">no additional details

</details><u>****docker-image-prune-3months****</u>

a script to remove all un-used docker images over 3 months old

```
#!/bin/bash
# docker-image-prune-3months.sh

echo "BEFORE $(docker image ls |wc -l)"
time docker image prune --all --filter "until=2160h"
echo "AFTER $(docker image ls |wc -l)"
```

<u>****docker-latest-images****</u>

pulls the latest docker images and restarts affected containers

```
#!/bin/bash
# docker-latest-images.sh 

find /home/docker/services -iname docker-compose.yml -exec docker compose -f "{}" pull \;
find /home/docker/services -mindepth 1 -maxdepth 1 -type d | while read -r DIR
do
	cd "${DIR}"
	TEST=$(docker compose ps -q)
	[ -z $TEST ] && cd "${DIR}" && docker compose up
	[ -z $TEST ] || echo "${DIR} not running"
done

```

<u>****further info****</u>

<details id="bkmrk-product-homelinkdocu"><table><colgroup><col style="width: 240px;"></col><col style="width: 240px;"></col></colgroup><tbody><tr><td><u>****Product Home****</u>

</td><td>n/a

</td></tr><tr><td><u>****Documentation****</u>

</td><td>n/a

</td></tr><tr><td><u>****Github****</u>

</td><td>n/a

</td></tr><tr><td><u>****DockerHub****</u>

</td><td>n/a

</td></tr><tr><td><u>****Misc****</u>

</td><td>n/a

</td></tr></tbody></table>

</details>