How to fix Error response from daemon: invalid reference format: repository name must be lowercase in Docker
The 'repository name must be lowercase' error occurs when you use uppercase characters in a Docker image name, tag, or related paths. Docker image references must be all lowercase. The fix is simple: convert all uppercase letters to lowercase in your image names and related configurations.
Quick fix
Fixes Error response from daemon: invalid reference format: repository name must be lowercase
# Wrong - uppercase letters
docker build -t MyApp:latest .
docker pull NginX:alpine
docker run -it Ubuntu:22.04
# Correct - all lowercase
docker build -t myapp:latest .
docker pull nginx:alpine
docker run -it ubuntu:22.04- Convert the image name to lowercase
- Fix uppercase in docker-compose.yml
- Fix uppercase in Dockerfile multi-stage builds
- Check and fix environment variables
# Wrong - uppercase lettersdocker build -t MyApp:latest .docker pull NginX:alpinedocker run -it Ubuntu:22.04# Correct - all lowercasedocker build -t myapp:latest .docker pull nginx:alpinedocker run -it ubuntu:22.04Error response from daemon: invalid reference format: repository name must be lowercase
What this error means
This error indicates that Docker's image reference parser encountered an uppercase letter where only lowercase is allowed. Docker follows strict naming conventions for image references based on DNS naming rules, which require all repository names to be lowercase. When you run commands like `docker build`, `docker pull`, or `docker run`, Docker parses the image reference (e.g., `myregistry.com/myrepo/myimage:tag`). If any part of the repository name contains uppercase letters, Docker rejects it with this error. The restriction exists because: 1. **DNS compatibility** - Registry hostnames must follow DNS rules, which are case-insensitive but conventionally lowercase 2. **Consistency** - Having a single canonical form prevents confusion between `MyImage` and `myimage` 3. **URL safety** - Image references are used in URLs, where case sensitivity can vary
Typical symptoms
- docker build fails with 'invalid reference format' before building any layers
- docker pull fails immediately without contacting the registry
- docker run fails with the error before attempting to start the container
- docker-compose up fails when image names contain uppercase letters
- CI/CD pipelines fail at image build or push steps
- The error appears despite the image name looking correct at first glance
Common causes
- Image name contains uppercase letters (e.g., 'MyApp' instead of 'myapp')
- Docker Compose service name has uppercase letters and is used to auto-generate image names
- Dockerfile multi-stage build uses uppercase in AS clause (e.g., 'FROM node AS BUILD')
- Environment variable used in image name is empty or contains uppercase (e.g., docker build -t $PROJECT_NAME)
- Working directory path contains uppercase letters when used with $(pwd) in volume mounts
- Path contains spaces that break the command parsing, making Docker misinterpret the image name
- Registry hostname or namespace contains uppercase letters
- Tag name contains uppercase letters (less common but still invalid)
How to fix "Error response from daemon: invalid reference format: repository name must be lowercase"
The most common fix is simply changing your image name to lowercase:
# Wrong - uppercase letters
docker build -t MyApp:latest .
docker pull NginX:alpine
docker run -it Ubuntu:22.04
# Correct - all lowercase
docker build -t myapp:latest .
docker pull nginx:alpine
docker run -it ubuntu:22.04Docker image names must only contain:
- Lowercase letters (a-z)
- Digits (0-9)
- Separators: periods (.), underscores (_), and hyphens (-)
Docker Compose auto-generates image names from the service name. If your service name has uppercase letters, the generated image name will too:
# Wrong - uppercase in service name
services:
MyService:
build: .
# Correct - lowercase service name
services:
myservice:
build: .Or explicitly set a lowercase image name:
services:
MyService:
build: .
image: myservice:latest # Explicit lowercase image nameWhen using multi-stage builds, the AS clause must also be lowercase:
# Wrong - uppercase stage name
FROM node:20 AS BUILD
RUN npm install
FROM node:20-slim AS RUNTIME
COPY --from=BUILD /app /app
# Correct - lowercase stage names
FROM node:20 AS build
RUN npm install
FROM node:20-slim AS runtime
COPY --from=build /app /appWhile some Docker versions may accept uppercase stage names, lowercase is the safe and recommended approach.
If you use environment variables in image names, ensure they're set and lowercase:
# Check if variable is set
echo $PROJECT_NAME
# If empty, the command becomes invalid
docker build -t :latest . # This causes the error!
# Fix: Ensure variable is set and lowercase
export PROJECT_NAME=myproject
docker build -t $PROJECT_NAME:latest .
# Or use lowercase transformation in bash
docker build -t ${PROJECT_NAME,,}:latest . # Bash 4+ lowercaseIn CI/CD pipelines, verify environment variables are properly passed to Docker commands.
Spaces in paths can cause Docker to misparse the command:
# Wrong - unquoted path with spaces breaks parsing
docker run -v $(pwd):/app myimage # If pwd = "/home/user/My Project"
# Correct - quote the entire volume argument
docker run -v "$(pwd):/app" myimage
# Or use $PWD with quotes
docker run -v "$PWD:/app" myimageIn PowerShell, use curly braces:
# PowerShell syntax
docker run -v "${pwd}:/app" myimageSome Docker operations may incorporate the working directory name. If your directory has uppercase letters, consider renaming it:
# Check current directory
pwd # Output: /home/user/MyProject
# Option 1: Rename the directory to lowercase
cd ..
mv MyProject myproject
cd myproject
# Option 2: Explicitly set a lowercase image name
docker build -t myproject:latest . # Don't rely on auto-namingThis is especially relevant when Docker Compose infers project names from directory names.
The full image reference includes registry and namespace, which must all be lowercase:
# Wrong - uppercase in registry or namespace
docker push MyRegistry.com/MyOrg/myimage:latest
docker pull GHCR.io/MyUser/myapp:v1
# Correct - everything lowercase
docker push myregistry.com/myorg/myimage:latest
docker pull ghcr.io/myuser/myapp:v1Check your Docker login and registry configuration:
# View current login credentials
cat ~/.docker/config.json | jq '.auths | keys'Advanced notes
### Why Lowercase Only?
Docker's image reference format follows the OCI (Open Container Initiative) distribution specification, which mandates lowercase repository names. This ensures:
1. Cross-platform compatibility - File systems handle case differently (Linux is case-sensitive, Windows/macOS often aren't)
2. URL safety - Registry URLs must work consistently across HTTP clients
3. DNS compliance - Registry hostnames follow DNS naming rules
### Automating Lowercase Conversion
In CI/CD pipelines, automatically convert to lowercase:
# Bash 4+
IMAGE_NAME=${REPO_NAME,,}
# POSIX-compatible
IMAGE_NAME=$(echo "$REPO_NAME" | tr '[:upper:]' '[:lower:]')
# In GitHub Actions
- name: Build image
run: |
IMAGE_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
docker build -t ghcr.io/$IMAGE_NAME:latest .### Regex for Valid Image Names
A valid Docker image name must match:
^[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+([._-][a-z0-9]+)*)*$The full reference (including registry and tag):
[registry/][namespace/]repository[:tag|@digest]### Common Mistakes in Different Environments
GitHub Actions:
# Wrong - repository may have uppercase
docker build -t ghcr.io/${{ github.repository }}:latest
# Correct - force lowercase
docker build -t ghcr.io/$(echo ${{ github.repository }} | tr A-Z a-z):latestGitLab CI:
# Use CI_PROJECT_PATH_SLUG which is already lowercase
docker build -t $CI_REGISTRY_IMAGE/$CI_PROJECT_PATH_SLUG:$CI_COMMIT_REF_SLUGJenkins:
def imageName = env.JOB_NAME.toLowerCase()
sh "docker build -t ${imageName}:${env.BUILD_NUMBER} ."Frequently asked questions
- What does "Error response from daemon: invalid reference format: repository name" mean?
- This error indicates that Docker's image reference parser encountered an uppercase letter where only lowercase is allowed. Docker follows strict naming conventions for image references based on DNS naming rules, which require all repository names to be lowercase. com/myrepo/myimage:tag).
- How do I fix "Error response from daemon: invalid reference format: repository name"?
- The 'repository name must be lowercase' error occurs when you use uppercase characters in a Docker image name, tag, or related paths. Docker image references must be all lowercase. The fix is simple: convert all uppercase letters to lowercase in your image names and related configurations.
- What causes "Error response from daemon: invalid reference format: repository name"?
- Image name contains uppercase letters (e.g., 'MyApp' instead of 'myapp') Docker Compose service name has uppercase letters and is used to auto-generate image names Dockerfile multi-stage build uses uppercase in AS clause (e.g., 'FROM node AS BUILD')
- Is the "Error response from daemon: invalid reference format: repository name" error serious?
- It is a low-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Docker Official Documentation
- ๐ฌStack Overflow - Repository name must be lowercase(Stack Overflow)
- ๐ฌStack Overflow - Lowercase images names in Docker(Stack Overflow)
- ๐
- ๐LabEx - Troubleshooting Invalid Reference Format Error(Official Docs)
- ๐
- ๐