This error occurs when your Docker client uses a newer API version than the daemon it is talking to can support. The fix is to lower the client's API version with DOCKER_API_VERSION, rely on API negotiation, or upgrade the daemon to match the client.
The Docker CLI and Docker Engine (daemon) communicate through a versioned HTTP API. When you run a Docker command, the client attempts to use a specific API version to talk to the daemon. This error appears when the client's API version is higher than the maximum version the daemon can handle — in other words, the daemon is too old for the client. This situation commonly occurs after upgrading the Docker CLI without updating the Docker Engine, when connecting to a remote Docker host running an older version, or when using newer tools (like docker-compose or Traefik) that target a newer API than your older daemon exposes. The API version is tied to specific Docker Engine releases; for example, API v1.44 corresponds to Docker Engine v25.0. The direction matters: "client version is too new" means you must point the client at a lower API version (or upgrade the daemon). It is the opposite of "client version is too old", which is about a client falling below the daemon's minimum supported API version.
First, identify the version mismatch by checking both client and server API versions:
docker versionThis displays both the Client and Server sections. Look for the "API version" lines:
Client:
Version: 24.0.7
API version: 1.43
Server:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)In this example, the client uses API 1.43 but the server only supports up to 1.41, so the client is too new for the daemon. Note the server's maximum supported version for the next step.
The quickest fix is to tell the client to use an older API version by setting the DOCKER_API_VERSION environment variable to the daemon's maximum supported version:
Linux/macOS (temporary):
export DOCKER_API_VERSION=1.41
docker ps # Should work nowLinux/macOS (permanent):
Add to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export DOCKER_API_VERSION=1.41' >> ~/.bashrc
source ~/.bashrcWindows PowerShell (temporary):
$env:DOCKER_API_VERSION="1.41"
docker psWindows PowerShell (permanent):
[Environment]::SetEnvironmentVariable("DOCKER_API_VERSION", "1.41", "User")Replace "1.41" with the maximum API version your server supports (from docker version).
The best long-term solution is to upgrade your Docker Engine so its supported API version meets or exceeds the client's:
Linux (using apt):
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginLinux (using yum/dnf):
sudo yum update docker-ce docker-ce-cli containerd.ioDocker Desktop (Windows/macOS):
1. Open Docker Desktop
2. Click the gear icon (Settings)
3. Go to "Software Updates"
4. Click "Check for updates" and install any available updates
Verify after upgrade:
docker versionThe Server API version should now be at least as high as the Client API version.
If you cannot upgrade the daemon (e.g., shared infrastructure, production constraints), you can downgrade the CLI to match the daemon:
Using Docker's version-specific packages (Linux):
# List available versions
apt-cache madison docker-ce-cli
# Install specific version
sudo apt-get install docker-ce-cli=5:20.10.21~3-0~ubuntu-jammyUsing Docker binaries directly:
1. Visit https://download.docker.com/linux/static/stable/
2. Download the version matching your daemon
3. Extract and replace the docker binary
Note: Downgrading means losing access to newer features. Prefer setting DOCKER_API_VERSION or upgrading the daemon when possible.
If the error occurs with docker-compose, set the API version before running compose commands:
export DOCKER_API_VERSION=1.41
docker-compose up -dFor docker-compose v2 (Docker Compose plugin):
export DOCKER_API_VERSION=1.41
docker compose up -dUsing an .env file:
You cannot set the API version directly in the compose YAML, but you can keep it in an .env file:
# .env file in same directory as docker-compose.yml
DOCKER_API_VERSION=1.41Then run:
docker-compose --env-file .env up -dWhen connecting to remote Docker hosts running older versions:
Using DOCKER_HOST with API version:
export DOCKER_HOST=tcp://remote-host:2375
export DOCKER_API_VERSION=1.40
docker psUsing Docker context:
# Create a context for the remote host
docker context create remote-server --docker "host=tcp://remote-host:2375"
# Set API version when using the context
export DOCKER_API_VERSION=1.40
docker --context remote-server psDocker Machine (if applicable):
# Upgrade the Docker Machine instance
docker-machine upgrade <machine-name>
# Or regenerate certificates
docker-machine regenerate-certs <machine-name>For tools like Traefik, Portainer, Watchtower, or Docker SDKs, prefer API version negotiation, and fall back to pinning a version the daemon supports:
Traefik:
Add to your Traefik configuration:
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
# Force a specific API version (check Traefik docs for syntax)Or upgrade Traefik to a version compatible with your Docker daemon.
Python docker SDK:
import docker
# Recommended: let the client auto-negotiate a compatible API version
client = docker.from_env()
# Or pin a version the daemon supports, passed at construction time
client = docker.from_env(version='1.41')
# Equivalent, when building the client explicitly
client = docker.DockerClient(
base_url='unix://var/run/docker.sock',
version='1.41',
)Note: pass version when constructing the client. Assigning client.api.version after construction is not the supported way to set the API version.
Go SDK:
cli, err := client.NewClientWithOpts(
client.FromEnv,
client.WithAPIVersionNegotiation(), // Auto-negotiate
)General approach:
Check if the tool supports setting DOCKER_API_VERSION via environment variable or has a configuration option for API version.
In CI/CD environments, set the API version in your pipeline configuration:
GitLab CI (.gitlab-ci.yml):
variables:
DOCKER_API_VERSION: "1.41"
build:
image: docker:latest
services:
- docker:dind
script:
- docker build -t myapp .GitHub Actions:
jobs:
build:
runs-on: ubuntu-latest
env:
DOCKER_API_VERSION: "1.41"
steps:
- uses: actions/checkout@v4
- name: Build
run: docker build -t myapp .Jenkins:
pipeline {
environment {
DOCKER_API_VERSION = '1.41'
}
stages {
stage('Build') {
steps {
sh 'docker build -t myapp .'
}
}
}
}Best practice: Pin Docker versions in CI to avoid unexpected version mismatches.
Understanding Docker API versioning:
Each Docker Engine release supports a range of API versions. The API is backward-compatible, meaning newer engines also support older API versions. The docker version command shows both the negotiated API version and the minimum supported version. API version negotiation was introduced in Docker v1.12.0 (API 1.24).
Which direction this error points:
This is the "client too new" error: the daemon is older than the client and rejects the client's higher API version. The fix is to lower the client's API version (via DOCKER_API_VERSION or negotiation) or upgrade the daemon. This is distinct from the "client too old" error, where a client falls below the daemon's *minimum* supported API version; raising a daemon's minimum (as some newer Engine releases do) affects that opposite case, not this one.
API version to Docker Engine version mapping (recent versions):
- API 1.48 = Docker Engine 27.4
- API 1.47 = Docker Engine 27.0 / 27.1
- API 1.46 = Docker Engine 26.1
- API 1.45 = Docker Engine 26.0
- API 1.44 = Docker Engine 25.0
- API 1.43 = Docker Engine 24.x
- API 1.42 = Docker Engine 23.x
- API 1.41 = Docker Engine 20.10.x
API version negotiation in SDKs:
Modern Docker SDKs support automatic API version negotiation, letting the client downgrade to a version the daemon supports. In Go: client.WithAPIVersionNegotiation(). In Python: use docker.from_env(), which negotiates automatically in recent versions. This is the most robust fix because it adapts to whatever daemon you connect to.
When DOCKER_API_VERSION won't work:
Setting a lower API version means some newer features won't be available. If your workflow requires features from a newer API version, you must upgrade the daemon. Note that setting DOCKER_API_VERSION *higher* than the daemon supports will not help — it only makes the mismatch worse; pin it at or below the daemon's maximum.
Troubleshooting persistent issues:
If the error persists after setting DOCKER_API_VERSION:
1. Ensure the environment variable is exported in the correct shell/context
2. For systemd services, set the variable in the service file's Environment section
3. For containers, pass it via -e DOCKER_API_VERSION=1.41
4. Check if multiple Docker installations exist on the system
Forgetting to unset DOCKER_API_VERSION:
If you set DOCKER_API_VERSION to work with an older host, remember to unset it when connecting to newer hosts, or you may unnecessarily limit the API features available.
Container exited with code 128: invalid exit argument
How to fix 'Container exited with code 128' in Docker
Error response from daemon: Get https://registry-1.docker.io/v2/: Proxy Authentication Required
How to fix 'Proxy Authentication Required' in Docker
error exporting cache: failed to export cache
How to fix 'error exporting cache: failed to export cache' in Docker
net/http: TLS handshake timeout
How to fix 'net/http: TLS handshake timeout' in Docker
Docker container exited with code 255
How to fix 'Container exited with code 255' in Docker