Skip to content

Instantly share code, notes, and snippets.

@mustafaturan
Last active January 19, 2024 01:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mustafaturan/934c0c3a7ad9e4e319868a8ac6d0b11e to your computer and use it in GitHub Desktop.
Save mustafaturan/934c0c3a7ad9e4e319868a8ac6d0b11e to your computer and use it in GitHub Desktop.
Install docker and run without sudo on Raspberry Pi
#!/bin/bash
curl -fsSL https://get.docker.com/rootless | sh
# Content to be added to .bashrc
content='export PATH="$HOME/bin:$PATH"'
# Check if content already exists in .bashrc
if grep -Fxq "$content" ~/.bashrc; then
echo "Content for bin path already exists in .bashrc. Skipping addition."
else
# Append content to .bashrc
echo "$content" >> ~/.bashrc
echo "Content for bin path added to .bashrc successfully."
fi
# Content to be added to .bashrc
dockerhost='export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock'
# Check if content already exists in .bashrc
if grep -Fxq "$dockerhost" ~/.bashrc; then
echo "Content for dockerhost already exists in .bashrc. Skipping addition."
else
# Append content to .bashrc
echo "$dockerhost" >> ~/.bashrc
echo "Content for dockerhost added to .bashrc successfully."
fi
#!/bin/bash
# Install docker
curl -sSL https://get.docker.com | sh
# Create docker user group
sudo groupadd docker
# Add current user to the docker group
sudo gpasswd -a $USER docker
# Apply changes
newgrp docker
# Install docker compose https://docs.docker.com/compose/install/linux/#install-using-the-repository
# exit (or reboot)
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment