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.
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
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'### 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} ."dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec
the input device is not a TTY
How to fix 'the input device is not a TTY' in Docker