DEV Community

Cover image for “docker.errors.DockerException: Error while fetching server API version: Not supported URL scheme http+docker”
Dmitry Romanoff
Dmitry Romanoff

Posted on

“docker.errors.DockerException: Error while fetching server API version: Not supported URL scheme http+docker”

If you encounter the error docker.errors.DockerException: Error while fetching server API version: Not supported URL scheme http+docker, it generally indicates that there is an issue with your Docker setup or that a reinstallation is required. In this guide, I'll walk you through the steps to resolve this issue and get Docker running smoothly again on Ubuntu 22.04. If you’re using a different operating system, the approach may need to be adjusted accordingly.

Causes of the Error
This error typically occurs when the Docker CLI cannot communicate with the Docker Daemon. Common reasons include:

  • Incorrect Docker installation
  • Conflicts between different Docker versions
  • Corrupted configurations

To resolve this error, follow these steps.

Step 1: Remove Old Docker Packages
Conflicts can sometimes arise from old or incorrectly installed Docker packages. Run the following commands to remove any potentially conflicting packages:

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Enter fullscreen mode Exit fullscreen mode

This command will remove old Docker versions and related packages.

Step 2: Add Docker’s Official Repository
You now need to add Docker’s official repository to get the latest version of Docker. Follow these steps:

Add Docker’s GPG key:

sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
Enter fullscreen mode Exit fullscreen mode

Add the Docker repository to Apt sources:

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-get update
Enter fullscreen mode Exit fullscreen mode

These commands add Docker’s repository to your system and update the package list.

Step 3: Install Docker and Dependencies
Now install Docker and the necessary components:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Enter fullscreen mode Exit fullscreen mode

Verify that Docker is installed and running:

sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

If everything is set up correctly, you should see a message from Docker confirming the successful execution of a test container.

Step 4: Install Docker Compose
To manage multi-container applications, use Docker Compose. Install it with the following steps:

Download the Docker Compose binary:

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode

Make the binary executable:

sudo chmod +x /usr/local/bin/docker-compose
Enter fullscreen mode Exit fullscreen mode

Check the Docker Compose version:

docker-compose --version
Enter fullscreen mode Exit fullscreen mode

These steps will install Docker Compose on your system, enabling you to manage multi-container applications.

Note for Other Operating Systems
This guide is specifically tailored for Ubuntu 22.04. If you are using a different operating system, such as another version of Ubuntu or a different Linux distribution, you may need to adjust these instructions accordingly.

Conclusion
By following the steps outlined above, you should be able to resolve the docker.errors.DockerException: Error while fetching server API version: Not supported URL scheme http+docker error and properly configure Docker and Docker Compose for successful operation. If the issue persists, make sure that the Docker Daemon is running and check your system configurations.

Top comments (0)