Skip to content

Commit

Permalink
Switch to Docker's apt repo for fresher releases
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Jun 11, 2024
1 parent a68eae9 commit a2eb04c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
23 changes: 16 additions & 7 deletions install/docker.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
sudo apt install -y docker.io docker-buildx
# Remove conflicting Docker packages
sudo apt purge --auto-remove docker.io docker-buildx docker-doc docker-compose docker-compose-v2 podman-docker containerd runc

# Add the official Docker repo
sudo install -m 0755 -d /etc/apt/keyrings
sudo wget -qO /etc/apt/keyrings/docker.asc https://download.docker.com/linux/ubuntu/gpg
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

# Install Docker engine and standard plugins
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

# Give this user privileged Docker access
sudo usermod -aG docker ${USER}

# Limit log size to avoid running out of disk
echo '{"log-driver":"json-file","log-opts":{"max-size":"10m","max-file":"5"}}' | sudo tee /etc/docker/daemon.json
echo '{"log-driver":"json-file","log-opts":{"max-size":"10m","max-file":"5"}}' | sudo tee /etc/docker/daemon.json > /dev/null

DOCKER_COMPOSE_VERSION="2.27.0"
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -sSL https://github.com/docker/compose/releases/download/v$DOCKER_COMPOSE_VERSION/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

# Default containers
sudo docker create --restart unless-stopped -p "127.0.0.1:3306:3306" --name=mysql8 -e MYSQL_ROOT_PASSWORD= -e MYSQL_ALLOW_EMPTY_PASSWORD=true mysql:8.4
sudo docker create --restart unless-stopped -p "127.0.0.1:6379:6379" --name=redis redis:7
sudo docker create --restart unless-stopped -p "127.0.0.1:5432:5432" --name=postgres16 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:16
3 changes: 2 additions & 1 deletion uninstall/docker.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sudo apt remove -y docker.io docker-buildx
sudo apt purge --auto-remove docker.io docker-buildx docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo rm -f "${DOCKER_CONFIG:-$HOME/.docker}/cli-plugins/docker-compose"
sudo groupdel docker

0 comments on commit a2eb04c

Please sign in to comment.