How to fix “Docker: Invalid Reference Format” error

Docker makes it easy to build, run, and manage containers. However, you may encounter an "Invalid Reference Format" error when running or building an image. In most cases, this is due to a minor formatting error in the image name or tag. For example, the error could be due to uppercase letters, special characters, or missing values. This guide will explain the common causes of this error and how to fix it to prevent it from happening again.

Fix "Invalid Reference Format" error

Let's find out the most common causes of the "Invalid Reference Format" error and how to fix them:

Capital letters in image names

Docker requires image names to be lowercase. Even a single uppercase letter can cause formatting errors. For example, running the following command will result in an error:

docker pull NGINX
How to fix “Docker: Invalid Reference Format” error
Archive names must be in lowercase

To avoid this error, always double check that your image name is in lowercase before running the command.

docker pull nginx
How to fix “Docker: Invalid Reference Format” error
Use lowercase letters

Special or invalid character

Sometimes users accidentally add characters that Docker doesn't allow. These include @ signs, spaces, or characters copied from a website or document that look normal but aren't.

For example, the following command contains the special character @, which will cause the following error:

docker run ubuntu@:latest
How to fix “Docker: Invalid Reference Format” error
Special character error

To fix this error, make sure there are no extra characters or formatting issues in the command. You can use a plain text editor to check and clean up the command (if necessary):

docker run ubuntu:latest
How to fix “Docker: Invalid Reference Format” error
Avoid special characters

Colon without tag

One of the most common mistakes is to put a colon at the end of the image name but not include the tag. For example, let's try the following command to pull Node:

docker pull node:

Docker expects a value after the colon, such as latest , 18-alpine , or any other valid tag. If no value is provided, the image name is considered incomplete and will cause an "Invalid Reference Format" error:

How to fix “Docker: Invalid Reference Format” error
Colon without tag

To fix this error, add an appropriate tag after the colon to make the image name full and valid:

docker pull node:latest
How to fix “Docker: Invalid Reference Format” error
Add tags after colon

File path or volume mount contains spaces

When you include a file path that contains spaces, especially with options like -v (volume mount), Docker may misinterpret parts of the path as separate arguments or even as part of the image name. As a result, you may encounter unexpected results like the one shown below:

docker run -v /home/user/My Folder:/app ubuntu
How to fix “Docker: Invalid Reference Format” error
Spaces in file names

To avoid this, always enclose the file path with spaces in double quotes, as shown below:

docker run -v "/home/user/My Folder:/app" ubuntu

Replace “/home/user/My Folder” with the actual path to the directory you want to mount into the container.

Inappropriate use of variables

When working with Docker, it is common to use variables in commands, especially when specifying image versions. However, if a variable like $VERSION is not set correctly, Docker can encounter issues like the "Invalid Reference Format" error.

For example, run the following command to pull Ubuntu from Docker Hub:

docker pull ubuntu:$VERSION

Here, $VERSION is supposed to represent the version of the Ubuntu image you want to pull. But if you don't assign a value to it, Docker will interpret the command as "docker pull ubuntu:". This results in an invalid image name because it ends with a colon and lacks the required version tag.

How to fix “Docker: Invalid Reference Format” error
Incorrect use of variables

To avoid this, make sure all variables used in the command are properly defined. In Linux, you can set a variable using the following syntax.

$VERSION=latest

Then pull the specified version by executing the following command.

docker pull ubuntu:$VERSION

In Windows CMD, you need to use the set keyword to define a variable (like version), then use the %VARIABLE% syntax to refer to it in commands like docker pull.

set VERSION=latest
docker pull ubuntu:%VERSION%

Here, $VERSION holds the most recent value, so Docker pulls the ubuntu:latest image without any problems. You can also assign a specific version, such as 18.04, if needed.

How to fix “Docker: Invalid Reference Format” error
Define variables properly

Copy and paste problem

Sometimes users copy commands from online tutorials or documentation. These copied commands may contain hidden characters such as invisible spaces, non-English punctuation, or special quotation marks. These characters can silently corrupt your Docker commands.

To avoid this, it's better to type the command yourself when possible, or paste the command into a plain text editor first to remove unwanted formatting.

Now that you know the common causes of the "Invalid Reference Format" error in Docker and how to fix it, you'll be well on your way to avoiding this problem in the future. From checking for capitalization to making sure your variables are set correctly, these simple tips can save you a lot of time and frustration. If you're ready to explore further, you might also want to learn how to tag and push your custom Docker images to the registry, or how to clean up unused images to keep your system clean.

Tags: #System
Sign up and earn $1000 a day ⋙

Leave a Comment

Fix Windows Error Code 0xc0000098: Backup ACPI.sys to Prevent Boot Failure

Fix Windows Error Code 0xc0000098: Backup ACPI.sys to Prevent Boot Failure

Error code 0xc0000098 in Windows causes a blue screen error on startup. The ACPI.sys driver is often to blame, especially on unsupported versions of Windows 11 like 23H2 or 22H2 or Windows 10.

Quickly fix Windows 10/8/7 computer error that freezes and cannot exit Safe Mode

Quickly fix Windows 10/8/7 computer error that freezes and cannot exit Safe Mode

In some cases, sometimes you start your computer in Safe Mode and the computer freezes. So how to fix the error in this case, please refer to the article below of WebTech360.

How to fix Snipping Tool keeps showing error

How to fix Snipping Tool keeps showing error

Snipping Tool is a powerful photo and video capture tool on Windows. However, this tool sometimes has some errors, such as constantly displaying on the screen.

How to get the fastest internet connection from your router

How to get the fastest internet connection from your router

Every network has a router to access the Internet, but not everyone knows how to make the router work better. In this article, we will introduce some router tips to help speed up the wireless connection in the network.

Common Mistakes When Performing Internet Speed ​​Tests

Common Mistakes When Performing Internet Speed ​​Tests

If the results seem slower than expected, don't be too quick to blame your ISP - mistakes when performing the test can skew your numbers.

What is QoS? How to use QoS for faster Internet speeds when you need it most

What is QoS? How to use QoS for faster Internet speeds when you need it most

In the article below, we will introduce and guide you to learn about the concept of QoS - Quality of Service on router devices.

Why cant this built-in Credential Manager feature in Windows replace a password manager?

Why cant this built-in Credential Manager feature in Windows replace a password manager?

Windows has a built-in Credential Manager, but it's not what you think it is—and certainly not a replacement for a password manager.

How to install free HEVC codecs on Windows 10 (for H.265 video)

How to install free HEVC codecs on Windows 10 (for H.265 video)

Microsoft charges for its official codecs and doesn't include them in Windows 10. However, you can get them for free without pulling out your credit card and spending $0.99.

Instructions to fix Access Denied error when accessing files or folders on Windows

Instructions to fix Access Denied error when accessing files or folders on Windows

While having trouble accessing files and folders can be frustrating, don't panic—with a few simple tweaks, you can regain access to your system.

How to check if USB Boot has been created successfully?

How to check if USB Boot has been created successfully?

After creating a USB boot to install Windows, users should check the USB boot's performance to see if it was created successfully or not.

4 Types of Windows Data That Are Growing in Size: How to Control Them?

4 Types of Windows Data That Are Growing in Size: How to Control Them?

Although Windows Storage Sense efficiently deletes temporary files, some types of data are permanent and continue to accumulate.

How to turn off background apps in Windows 11, reduce RAM consumption on Win 11

How to turn off background apps in Windows 11, reduce RAM consumption on Win 11

You can turn off Windows 11 background apps to optimize performance, save battery and reduce RAM consumption.

Instructions to fix the error “Network path was not found” in Windows

Instructions to fix the error “Network path was not found” in Windows

When a computer, mobile device, or printer tries to connect to a Microsoft Windows computer over a network, for example, the error message network path was not found — Error 0x80070035 may appear.

How to block Internet connection of Windows 10 software and applications

How to block Internet connection of Windows 10 software and applications

We can block Internet access for any application or software on the computer, while other programs can still access the network. The following article will guide readers on how to disable Internet access for software and applications on Windows.

How to Stay Safe on Windows 10 Until 2030

How to Stay Safe on Windows 10 Until 2030

Instead of paying $30 for a year of security updates, keep Windows 10 safe until 2030 with this simple solution.

Fix Windows Error Code 0xc0000098: Backup ACPI.sys to Prevent Boot Failure

Fix Windows Error Code 0xc0000098: Backup ACPI.sys to Prevent Boot Failure

Error code 0xc0000098 in Windows causes a blue screen error on startup. The ACPI.sys driver is often to blame, especially on unsupported versions of Windows 11 like 23H2 or 22H2 or Windows 10.

Quickly fix Windows 10/8/7 computer error that freezes and cannot exit Safe Mode

Quickly fix Windows 10/8/7 computer error that freezes and cannot exit Safe Mode

In some cases, sometimes you start your computer in Safe Mode and the computer freezes. So how to fix the error in this case, please refer to the article below of WebTech360.

How to fix Snipping Tool keeps showing error

How to fix Snipping Tool keeps showing error

Snipping Tool is a powerful photo and video capture tool on Windows. However, this tool sometimes has some errors, such as constantly displaying on the screen.

How to get the fastest internet connection from your router

How to get the fastest internet connection from your router

Every network has a router to access the Internet, but not everyone knows how to make the router work better. In this article, we will introduce some router tips to help speed up the wireless connection in the network.

Common Mistakes When Performing Internet Speed ​​Tests

Common Mistakes When Performing Internet Speed ​​Tests

If the results seem slower than expected, don't be too quick to blame your ISP - mistakes when performing the test can skew your numbers.

What is QoS? How to use QoS for faster Internet speeds when you need it most

What is QoS? How to use QoS for faster Internet speeds when you need it most

In the article below, we will introduce and guide you to learn about the concept of QoS - Quality of Service on router devices.

Why cant this built-in Credential Manager feature in Windows replace a password manager?

Why cant this built-in Credential Manager feature in Windows replace a password manager?

Windows has a built-in Credential Manager, but it's not what you think it is—and certainly not a replacement for a password manager.

How to install free HEVC codecs on Windows 10 (for H.265 video)

How to install free HEVC codecs on Windows 10 (for H.265 video)

Microsoft charges for its official codecs and doesn't include them in Windows 10. However, you can get them for free without pulling out your credit card and spending $0.99.

Instructions to fix Access Denied error when accessing files or folders on Windows

Instructions to fix Access Denied error when accessing files or folders on Windows

While having trouble accessing files and folders can be frustrating, don't panic—with a few simple tweaks, you can regain access to your system.

How to check if USB Boot has been created successfully?

How to check if USB Boot has been created successfully?

After creating a USB boot to install Windows, users should check the USB boot's performance to see if it was created successfully or not.

4 Types of Windows Data That Are Growing in Size: How to Control Them?

4 Types of Windows Data That Are Growing in Size: How to Control Them?

Although Windows Storage Sense efficiently deletes temporary files, some types of data are permanent and continue to accumulate.

How to turn off background apps in Windows 11, reduce RAM consumption on Win 11

How to turn off background apps in Windows 11, reduce RAM consumption on Win 11

You can turn off Windows 11 background apps to optimize performance, save battery and reduce RAM consumption.

Instructions to fix the error “Network path was not found” in Windows

Instructions to fix the error “Network path was not found” in Windows

When a computer, mobile device, or printer tries to connect to a Microsoft Windows computer over a network, for example, the error message network path was not found — Error 0x80070035 may appear.

How to block Internet connection of Windows 10 software and applications

How to block Internet connection of Windows 10 software and applications

We can block Internet access for any application or software on the computer, while other programs can still access the network. The following article will guide readers on how to disable Internet access for software and applications on Windows.

How to Stay Safe on Windows 10 Until 2030

How to Stay Safe on Windows 10 Until 2030

Instead of paying $30 for a year of security updates, keep Windows 10 safe until 2030 with this simple solution.