A comprehensive bash script to set up Docker, Docker Compose, and GitHub CLI on Ubuntu/Debian systems with proper permissions and user configuration.
- ✅ System package updates
- ✅ Docker Engine installation (if not present)
- ✅ Docker Compose V2 plugin installation
- ✅ GitHub CLI (gh) installation
- ✅ Docker group configuration with proper permissions
- ✅
/srv/containers/directory creation with ACL support - ✅ User added to docker group for sudo-less operation
- ✅ Comprehensive error handling and status reporting
curl -sL https://raw.githubusercontent.com/alexisskeates/docker-setup-script/main/docker-setup.sh | sudo bash# Download the script
curl -sL https://raw.githubusercontent.com/alexisskeates/docker-setup-script/main/docker-setup.sh -o docker-setup.sh
# Make it executable
chmod +x docker-setup.sh
# Run it
sudo ./docker-setup.sh- Updates package lists
- Upgrades existing packages
- Reports number of packages updated
- Checks if Docker is installed
- Adds Docker's official GPG key and repository
- Installs Docker Engine, CLI, containerd, and plugins
- Enables Docker service to start on boot
- Verifies Docker daemon is running
- Creates docker group if it doesn't exist
- Adds the current user to the docker group
- Sets up proper permissions for group access
- Checks for Docker Compose V2 plugin
- Installs if missing
- Verifies installation
- Checks if
ghis installed - Adds GitHub CLI repository
- Installs the latest version
- Verifies installation
- Creates
/srv/containers/directory - Sets ownership to
root:docker - Applies
770permissions (rwxrwx---) - Configures ACL for inherited permissions
- Ensures all docker group members can access
- Tests Docker access for the user
- Provides summary of all installed components
- Lists next steps for activation
After running the script, you'll need to activate the docker group membership:
# Log out and log back in
exit# Start a new shell with docker group active
newgrp dockerdocker --version
docker compose version
docker ps
gh --version- OS: Ubuntu 20.04+ or Debian 10+
- Privileges: Must be run with
sudo - Network: Internet connection required for package downloads
The script creates /srv/containers/ with the following permissions:
Owner: root (rwx)
Group: docker (rwx)
Others: --- (no access)
This allows all members of the docker group to:
- Create containers in
/srv/containers/ - Manage docker-compose projects
- Share container configurations
This is normal. The docker group membership requires a new login session. Use newgrp docker or log out/in.
Check your internet connection and ensure apt sources are configured correctly.
Try: sudo systemctl start docker and check logs with sudo journalctl -u docker
- The script must be run with
sudoprivileges - All docker group members have full access to
/srv/containers/ - Docker group membership is equivalent to root access
- Only add trusted users to the docker group
After installation, you'll have:
/srv/containers/ # Root directory for all containers
├── (your projects) # Docker Compose projects
└── ...
MIT License - See LICENSE file for details
Issues and pull requests are welcome! Please feel free to contribute improvements.
Alexis Keates - GitHub
If you encounter any issues, please open an issue on GitHub.