Created
December 4, 2025 18:43
-
-
Save Wultyc/7a4b0c4fb72085ac24827262086e86db to your computer and use it in GitHub Desktop.
Install docker compose on Unraid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ### Config Properties | |
| bin_destination="./output/docker-compose" #"/usr/local/bin/docker-compose" | |
| bin_cache_destination="./output/docker-compose-cache" #"/boot/config/docker-compose" | |
| default_version="v2.40.3" | |
| check_latest=false | |
| proceed_if_error=true | |
| ### End Config Properties | |
| ### Automatic Params | |
| version="" | |
| ### End Automatic Params | |
| ### Functions | |
| log(){ | |
| local level="" | |
| local msg="" | |
| if [ -z "$2" ]; then | |
| level="INFO" | |
| msg=$1 | |
| else | |
| level=$1 | |
| msg=$2 | |
| fi | |
| echo "[$level] $msg" | |
| } | |
| log_error(){ | |
| log "ERROR" "$1" | |
| } | |
| check_latest_version() { | |
| curl -s https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | |
| } | |
| ### End Funtions | |
| # Make cache localtion ready | |
| log "Ensuring cache location exists" | |
| mkdir -p $bin_cache_destination | |
| # Check version | |
| if [[ "$check_latest" == "true" ]]; then | |
| version=$(check_latest_version) | |
| if [ -z "$version" ]; then | |
| log_error "Unable to check latest version from web" | |
| if [ $proceed_if_error != "true" ]; then log_error "Aborting..." ;exit -1; fi | |
| log "Getting the latest version from cache" | |
| version=$(ls $bin_cache_destination | sort -n | tail -1) | |
| if [ -z "$version" ]; then log_error "Cache is empty. Aborting..." ;exit -1; fi | |
| fi | |
| else | |
| version=$default_version | |
| fi | |
| log "Will be installed docker compose version $version" | |
| log "Check if $version is available in cache" | |
| if [ -e "$bin_cache_destination/$version" ]; then | |
| log "$version available in cache. Skiping download" | |
| else | |
| log "Downloading $version and saving it to cache folder" | |
| wget "https://github.com/docker/compose/releases/download/$version/docker-compose-linux-x86_64" -O "$bin_cache_destination/$version" >> /dev/null | |
| if [ $? -ne 0 ]; then | |
| log_error "Error downloading $version from web" | |
| if [ $proceed_if_error != "true" ]; then log_error "Aborting..." ;exit -1; fi | |
| log "Getting the latest version from cache" | |
| version=$(ls $bin_cache_destination | sort -n | tail -1) | |
| if [ -z "$version" ]; then log_error "Cache is empty. Aborting..." ;exit -1; fi | |
| fi | |
| fi | |
| log "Copying the file" | |
| cp "$bin_cache_destination/$version" "$bin_destination" | |
| log "Making $bin_destination executable" | |
| chmod +x $bin_destination | |
| log "Installation complete" | |
| log "Checking installation" | |
| source ~/.bashrc | |
| docker-compose --version | |
| # Confirma a conclusão | |
| if [ $? -eq 0 ]; then | |
| log "Docker Compose $version installed successfully!" | |
| else | |
| log_error "Installation failed. Check logs for more details" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment