1

I see somewhere in an example of docker tagging as below.

docker build -t example.com:80/hw-go:1.2 .

What I could not get is why "example.com:80" is being used here instead of "user-name" as normal convention. Generally, tagging is does in below format

docker build -t <user-name>/<image-name>:<tag-name>

Any specific reason to use an example url and port instead of user-name? This image is build locally and saved locally as well.

/home/ravi> sudo docker images
REPOSITORY                                                TAG            IMAGE ID       CREATED          SIZE
example.com:80/ad                                         1.2            a285e31adfc6   30 minutes ago   736MB
registry.k8s.io/sig-storage/nfs-provisioner               v4.0.8         fd0b16f70b66   12 days ago      236MB
nexus3.o-ran-sc.org:10002/o-ran-sc/ric-plt-a1             3.0.1          49090bccc5e6   3 months ago     140MB

docker info output

/home/ravi/#docker info
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 107
  Running: 52
  Paused: 0
  Stopped: 55
 Images: 47
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 
 runc version: 
 init version: 
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.15.0-67-generic
 Operating System: Ubuntu 20.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.63GiB
 Name: ubuntu-temp
 ID: GXHN:P4BG:HMYJ:4PTJ:LIMA:MOE2:ECRL:2ZCI:YRNI:B5YH:DN3U:JPK4
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

thanks

1 Answers1

1

The first part of the tag is the registry URL (to which registry the image can be pushed or pulled from). Normally it is missing because Docker implies the docker hub.

Placing anything else before the registry name (the username in your example) will tell Docker to use a different registry then the default one.

So in your example there should be a docker registry running at example.com:80 where you could push this image.

Mihai
  • 9,526
  • 2
  • 18
  • 40
  • but I am not running any docker registry exclusively. my "docker image" shows default which gets created for any docker image building normally. i have added docker image output in main thread. for your reference – myquest5 sh Mar 20 '23 at 04:42
  • Seems very odd that Docker would add that registry on its own... If you run `docker info`, what do you see under Registry? – Mihai Mar 20 '23 at 05:07
  • i have added docker info log in main thread. plz have a look – myquest5 sh Mar 20 '23 at 05:46
  • If you don't run a registry you can't push the image you built, but you can still name it like this on your machine. Example.com is the registry and NOT a user-name and the tag is 1.2. The docker info is not relevant for your question. – sleepyhead Mar 20 '23 at 06:06
  • @sleepyhead i got it that i can not push my image. but can i use it locally by using docker run ? will it have any implication of not having actual example.com:80 registry? – myquest5 sh Mar 20 '23 at 07:15
  • @myquest5sh From what I see there is no way that Docker would tag the image with a local registry, unless to tell it to. Could it be that you did it by copying from an example? If it were me I would run `history | grep "example.com"` just to rule it out. If you do find out that it was Docker please share because I am very curious. – Mihai Mar 20 '23 at 07:22
  • yes, you can run it locally where you built and named it. The registry is only needed to transfer images, but it is built locally. It doesn't make sense to name it on a registry that doesn't exist, but that's why it's an example. You named it example.com by following a tutorial, docker didn't do it by itself. You can give the same image also another name which you use locally or push to another registry – sleepyhead Mar 20 '23 at 08:11
  • @mihai yes i copied it from an example as already said earlier. but that example does not say to setup any private registry example.com:80. it just build like that. i wanted to understand then why that example has added this registry tag he could have used normal username tagging – myquest5 sh Mar 20 '23 at 08:13