Setting up Docker on the server
1. Install Docker
Update System and Install Prerequisites
# Update package index
sudo apt-get update
# Install required packages
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-releaseAdd Docker Repository
# Create directory for Docker GPG key
sudo mkdir -m 0755 -p /etc/apt/keyrings
# Download and add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Add Docker repository to apt sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullInstall Docker Engine
2. Configure User Permissions
3. Start and Enable Docker Service
4. Apply Group Changes
5. Verify Installation
6. Verify Everything is Working
Troubleshooting
If Permission Denied Still Occurs
If Docker Service Won't Start
Security Considerations for EC2
Quick One-Liner Installation
Post-Installation Optional Steps
Install Docker Compose (Standalone)
Configure Docker Logging
Useful Docker Commands
Last updated