Install required ubuntu dependencies
#!/bin/bash
# Script to install packages to avoid problems on an ubuntu machine
# Update to get latest releases
apt update
# Problem: curl: command not found
apt install curl -y
# Problem: apt-get-repository command not found / is missing
apt install software-properties-common python-software-properties -y
# Problem:
# E: The method driver /usr/lib/apt/methods/https could not be found.
# N: Is the package apt-transport-https installed?
# E: Failed to fetch https://download.docker.com/linux/ubuntu/dists/xenial/InRelease
# E: Some index files failed to download. They have been ignored, or old ones used instead.
apt install apt-transport-https
#!/bin/bash
# Script to install docker community edition on ubuntu using official docker repositories
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common
# add the GPG key for the official Docker repository to the system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
# Add the Docker repository to APT sources
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Update the package database with the Docker packages from the newly added repo
apt-get update
# Install Docker
apt-get install -y docker-ce
# Run hello-world container
docker run hello-world
# avoid typing whenever you run the docker command, add your username to the docker group:
usermod -aG docker ubuntu
# enable Docker to run when your system boots
systemctl enable docker
Install Docker Compose
#!/bin/bash
# Script to install docker compose
# Get latest version from https://github.com/docker/compose/releases
dockercomposeVersion='1.17.1';
curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# Fix: /usr/local/bin/docker-compose: Permission denied
chmod +x /usr/local/bin/docker-compose
The old way to free disk space
#!/bin/bash
# Script to clean up docker containers, volumes and images to help free disk space
echo 'Stopping exited containers'
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker stop -v
echo 'Removing unused images'
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
echo 'Removing exited containers'
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
echo 'Removing unused volumes'
docker volume ls -qf dangling=true | xargs -r docker volume rm