what is the use of url in docker tagging

354 views Asked by At

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

There are 1 answers

8
Mihai On

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.