The error occurs due to two separate issues: an obsolete version attribute in your Docker Compose file and insufficient permissions to access the Docker daemon. Here’s how to fix both:
1. Remove the Obsolete version Attribute
Problem:
The version field in docker-compose.pprd.yml is no longer supported in modern Docker Compose versions.
Fix:
Edit your docker-compose.pprd.yml and remove the version line (e.g., version: '3').
Example corrected YAML:
services:
my_service:
image: beep-pprd
# ... rest of your config
2. Fix Docker Daemon Permission Issues
The error permission denied while trying to connect to the Docker daemon socket indicates your user lacks permissions to interact with Docker.
Step 1: Add Your User to the docker Group
sudo usermod -aG docker $USER
Note: You’ll need to log out and back in (or restart your shell) for this to take effect.
Step 2: Verify Docker Permissions
Ensure the Docker socket has proper permissions:
sudo chmod 666 /var/run/docker.sock
Step 3: Restart Docker (If Needed)
sudo systemctl restart docker
3. If Using Podman (via podman-docker)
If you’re using Podman (instead of Docker), ensure Podman is running and accessible:
# Check if Podman is running
podman info
# If using Podman's Docker compatibility layer, verify the socket path
ls -l /var/run/docker.sock # Should point to Podman's socket
4. Test the Fix
Run your command again:
docker compose -f docker-compose.pprd.yml up --build -d
Why This Works
- The
version field was deprecated in Docker Compose v1.27.0+ and causes warnings/errors in newer versions.
- The
docker group grants your user permission to communicate with the Docker daemon via /var/run/docker.sock.
Let me know if you still encounter issues!