Why does docker think I want `root:latest`?

I’m trying to create a container called pny using my local pny-img that I just successfully built using the root user.

My build
docker build /home/pny-build/ -t root/pny-img:latest

Why does docker think I want root:latest? (also I have not published to docker hub nor do I want to)

root@h:/# docker run -itd --ip6 --user root --mount /home/host:/home/msg -v pny-data:/home/PNY/data --name pny root/pny-img:latest
Unable to find image 'root:latest' locally
docker: Error response from daemon: pull access denied for root, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
docker image ls
REPOSITORY     TAG       IMAGE ID       CREATED          SIZE
root/pny-img   latest    e155807a2b41   13 minutes ago   154MB
<none>         <none>    3e69001ca458   20 minutes ago   100MB
root/peonyd    latest    afec8964fc47   25 hours ago     149MB
ubuntu         22.04     2dc39ba059dc   9 days ago       77.8MB
docker         latest    0dfb722b2a54   2 weeks ago      134MB

Even if I use the image id

root@h:/# docker run -itd --ip6 --user root --mount /home/host:/home/msg -v pny-data:/home/PNY/data --name pny e155807a2b41 
Unable to find image 'root:latest' locally

That’s a strange behavior. Haven’t seen it before. Though, I never used the context as first argument, as the documentation says:

Usage:  docker build [OPTIONS] PATH | URL | -

The context is either a path, an url or a Dockerfile piped in using stdin.

It is not necessary to publish the image before using it. Many images use dashes. So make sure yours uses an actual typed dash. Apart from those suggestions: I have no idea why you experience what your experience.

what is a typed dash?

how come I can remove it but not run it?

docker image rm root/pny-img
Untagged: root/pny-img:latest
Deleted: sha256:3f125f37c7140ee794f54c566a40080638562a003bfc03413838259308062abe
Deleted: sha256:acce67e57a7d91a533ab8e5cb13b682fad8ed8455fe34f977d17707b4bfccde5
Deleted: sha256:bc5715aac2dfb671183c9d1403522387fa1c5f0e6018fb254790716020e95639
Deleted: sha256:275d383b329907af028653cd4ce60ebd95339b08c8511d355d3884edcf542400
Deleted: sha256:2673dae7a7c9e675e0dadf162f5927b2424e0bd3ab67efe2013056f547e021f5
Deleted: sha256:d41949c0a3d0f77a37af0a02b73fff5911baab90fe816cd64d2bc0a031df8d2c
Deleted: sha256:c54d85e27a8bf35edf77e46a646b14cab6d77d484aca312996007921ab78d944

crazy!

Typed with the keyboard. Sometimes if text is copied from documents or web pages, it happens that characters that look like a dash are copied, but in fact are not the dash character.

This makes it indeed more confusing.

Ah, ok, It’s not copied

If I remove --name root I get a different error message invalid reference format

root@h:/# docker run -itd --ip6 --mount /home/host:/home/msg -v pny-data:/home/PNY/data --name pny root/pny:1
docker: invalid reference format.
See 'docker run --help'.

root@h:/# docker run -itd --ip6 --mount /home/host:/home/msg -v pny-data:/home/PNY/data --name pny pny:1
docker: invalid reference format.
See 'docker run --help'.

root@h:/# docker run -itd --ip6 --mount /home/host:/home/msg -v pny-data:/home/PNY/data --name pny pny
docker: invalid reference format.
See 'docker run --help'.

root@h:/# docker run -itd --ip6 --mount /home/host:/home/msg -v pny-data:/home/PNY/data --name pny root/pny
docker: invalid reference format.
See 'docker run --help'.

You are missing the argument to the --ip6 parameter.

And that was always missing. That’s why --user became the argument of --ip6 and root is just an argument of docker run. Since the first argument of docker run is the image name, it tried to run root:latest

2 Likes

Good catch on the first command, I didn’t spot it back then.