Deleting images from UI is not getting reflected in backend.
karthiksonti24 opened this issue ยท 12 comments
I tried deleting old Docker images from UI to reduce my memory usage by images, it's getting deleted in UI, but in the backend, it shows the same memory as before doing deletion.
Any idea on this?
Hello, thank you for your issue and using my project ๐
In order to delete images in the backend, you need ty execute this command on the host: registry garbage-collect config.yml
This will run the garbage collector in the registry and remove dangling images. This is not automatic ๐
When you delete an image, the UI says:
Deleting my-docker-image:latest image. Run
registry garbage-collect config.yml
on your registry
I will also add this command in the FAQ, thx :)
Thanks for the reply. I tried what you have suggested. Encountered with the below error. Am I missing something?
[root@xl-docker docker-registry]# docker exec 7874e42c1756 registry garbage-collect config.yml
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"registry\": executable file not found in $PATH": unknown
You are running this in the registry container? Not the UI?
Yes, I'm running it inside the server where my container is up. Not on UI.
Hum.... Can I have the output of
docker inspect 7874e42c1756
Here you go -
[root@xl-docker ksonti]# docker inspect 7874e42c1756
[
{
"Id": "7874e42c1756033c48b06e53f349f06e2ab3633caa4465b12c21d01ac7d24be6",
"Created": "2020-08-18T06:10:35.383899532Z",
"Path": "/bin/sh",
"Args": [
"-c",
"entrypoint"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1643,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-08-18T06:10:35.712536207Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:c38216cd93c43feb7dc6cfd11a5d235f56665ae0a35e454daa68a131543e5e82",
"ResolvConfPath": "/var/lib/docker/containers/7874e42c1756033c48b06e53f349f06e2ab3633caa4465b12c21d01ac7d24be6/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/7874e42c1756033c48b06e53f349f06e2ab3633caa4465b12c21d01ac7d24be6/hostname",
"HostsPath": "/var/lib/docker/containers/7874e42c1756033c48b06e53f349f06e2ab3633caa4465b12c21d01ac7d24be6/hosts",
"LogPath": "/var/lib/docker/containers/7874e42c1756033c48b06e53f349f06e2ab3633caa4465b12c21d01ac7d24be6/7874e42c1756033c48b06e53f349f06e2ab3633caa4465b12c21d01ac7d24be6-json.log",
"Name": "/dockerregistry_registry-ui_1",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": [],
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/d42353c6123ecae56e9d127575f92b651a93104662de65d1cbfc52987352d30f-init/diff:/var/lib/docker/overlay2/815435cdd4e99c5bb383d8847bd98e63d67afa85ca3c6f1bcd06eab49e0bfaef/diff:/var/lib/docker/overlay2/bddca469ff948c48be3ce0c0169299c4dacef1fb591bbecfd68fdf77f0aa324c/diff:/var/lib/docker/overlay2/64879a86e40dec40d41f7b26e661ff0661708e17c572075b6e51358be9c003d0/diff:/var/lib/docker/overlay2/67a97aa9fcc497400a639ddaa7bfdef09152c45182f80394e173fecf2fda12a0/diff:/var/lib/docker/overlay2/c189f0d1e57437839155abeb7e1c3e490bb2f190fec862c01148113147713a85/diff:/var/lib/docker/overlay2/6be69c5bda4e8ee6cba72468c793abea444dd1eeb6a173dda87fbf9c4b9fe84c/diff:/var/lib/docker/overlay2/63dead37d5832a2e93399edea74f1a1a81b92b11d86d03d6e922a29225d2e1ce/diff:/var/lib/docker/overlay2/f0b9bcd064689fa2c7eb532c73e9fae7af2972a872a599e618a345596af4b8a4/diff:/var/lib/docker/overlay2/5c1e661aae400c55d9eb882e38ca73191a11cf58c86956bafba94a696959d6be/diff",
"MergedDir": "/var/lib/docker/overlay2/d42353c6123ecae56e9d127575f92b651a93104662de65d1cbfc52987352d30f/merged",
"UpperDir": "/var/lib/docker/overlay2/d42353c6123ecae56e9d127575f92b651a93104662de65d1cbfc52987352d30f/diff",
"WorkDir": "/var/lib/docker/overlay2/d42353c6123ecae56e9d127575f92b651a93104662de65d1cbfc52987352d30f/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "7874e42c1756",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"URL=https://xl-docker.xebialabs.com",
"DELETE_IMAGES=true",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.19.0",
"NJS_VERSION=0.4.1",
"PKG_RELEASE=1",
"NGINX_PROXY_HEADER_Host=$http_host"
],
"Cmd": null,
"Image": "joxit/docker-registry-ui:static",
"Volumes": null,
"WorkingDir": "/usr/share/nginx/html",
"Entrypoint": [
"/bin/sh",
"-c",
"entrypoint"
],
"OnBuild": null,
"Labels": {
"com.docker.compose.config-hash": "3287e710102e2e6a9a2dc932e89157b2151efd156c6ed405606f1b4fad5242a7",
"com.docker.compose.container-number": "1",
"com.docker.compose.oneoff": "False",
"com.docker.compose.project": "dockerregistry",
"com.docker.compose.service": "registry-ui",
"com.docker.compose.version": "1.17.1",
"maintainer": "Jones MAGLOIRE @Joxit"
},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "898ffcc1b0971717656abd8f391fe81b5013de9bf8d1ddaa10aa9445177c3822",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/898ffcc1b097",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "3b2c7722a0790c396c69a8364599a3403e0a40fe41277eedcf932a1ce97c1671",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "b7de44b6df9cf580765de88ab176b104ed86a40520cc52bd2a23342b73073495",
"EndpointID": "3b2c7722a0790c396c69a8364599a3403e0a40fe41277eedcf932a1ce97c1671",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
}
}
}
}
]
Ok, you need to run the command registry garbage-collect config.yml
in your docker registry container (the container with the image name registry:2
for example)
That works absolutely fine. Thanks, Jones ๐
You are welcome ๐
For anyone battling to run this via kubectl:
kubectl exec -it -n registry deploy/registry-docker-registry -- /bin/registry garbage-collect /etc/docker/registry/config.yml
Hey @Joxit I deleted the tags from the UI and ran garbage collection on the registry pod. but the used space is still the same. What could be the issue?
Hello @allandereal , as a first guess, I would say you deleted a tag which is based on images that are used by other images/tags. Since Docker is based on layers, the garbage collector removed only the smallest layers on top ?
Since I'm using the docker registry server API, if you don't see the image on the UI that means it's unlikely an issue from my project.