Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker run throws "invalid reference format: repository name must be lowercase" using $(pwd) in volume flag

Tags:

shell

docker

docker run throws an "invalid reference format: repository name must be lowercase" error when using $(pwd) in the volume flag (-v). This is the command that is currently causing the issue:

docker run --rm -v $(pwd)/app/polymer:/home/polymer/app jefferyb/polymer-cli polymer build
like image 692
Will Squire Avatar asked Jan 01 '18 21:01

Will Squire


People also ask

How to fix docker invalid reference format?

How to fix - docker: invalid reference format: repository name must be lowercase? The simplest way to fix the issue by change the image to jhooq-docker-demo so that there is no uppercase character in the image name .

How do I run an image in docker?

To run an image inside of a container, we use the docker run command. The docker run command requires one parameter and that is the image name. Let's start our image and make sure it is running correctly.

What is -- RM in docker run?

The --rm causes Docker to automatically remove the container when it exits. The image being used to create the container is generally specified as <name>:<tag> such as ruby:latest . If the specified image is not available locally, Docker will attempt to retrieve it from Docker Hub (or any connected Docker registry).

Why is my repository name invalid in Docker?

invalid reference format: repository name must be lowercase This means the reference we are using should not have uppercase letters. Try running docker run Ubuntu (wrong) vs docker run ubuntu (correct). Docker does not allow any uppercase characters as an image reference.

What is an invalid reference format error in Docker?

A "reference" in docker is a pointer to an image. It may be an image name, an image ID, include a registry server in the name, use a sha256 tag to pin the image, and anything else that can be used to point to the image you want to run. The invalid reference format error message means docker cannot convert the string you've provided to an image.

Why does $(PWD) in the volume flag ( -V) throw an error?

docker run throws an "invalid reference format: repository name must be lowercase" error when using $ (pwd) in the volume flag ( -v ). This is the command that is currently causing the issue: FYI, $ (pwd) is extremely inefficient compared to "$PWD".

What is a reference in dockerfile?

Basically a reference in docker is a pointer to image, so whenever you use image name inside your Dockerfile or docker command it get parsed and the image name should follow certain rules as described in below in the table of content -


1 Answers

For my own circumstance, the output of pwd contained a directory with a space (i.e. /something/Problematic Directory/something-else). This was resolved by wrapping $(pwd) in quotation marks to explicitly identify it as a string:

docker run --rm -v "$(pwd)/app/polymer":/home/polymer/app jefferyb/polymer-cli polymer build

The documentation I read didn't use quotation marks, however this might be better practise when using variable interpolation in shell to avoid these kind of issues.

like image 107
Will Squire Avatar answered Sep 19 '22 13:09

Will Squire