burnettk / delete-docker-registry-image

If you are running a private v2 docker registry, and you are storing your data on disk, running this script from the machine where the data lives will let you fully delete an image or tag

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to delete?can`t find REGISTRY_DATA_DIR.

Toplife opened this issue · comments

Hi,
delete_docker_registry_image --image localhost:5000/cs/hello-world:8.0
CRITICAL [2016-03-02 21:26:01,938] No repository 'localhost:5000/cs/hello-world:8.0' found in repositories directory /var/lib/docker/repositories
I can`t find REGISTRY_DATA_DIR,pls help...

you want to omit the localhost:5000/ in the image reference. ls
/var/lib/docker/repositories
to get an idea of the structure.

On Thu, Mar 3, 2016 at 3:19 AM, David guo notifications@github.com wrote:

Hi,
delete_docker_registry_image --image localhost:5000/cs/hello-world:8.0
CRITICAL [2016-03-02 21:26:01,938] No repository
'localhost:5000/cs/hello-world:8.0' found in repositories directory
/var/lib/docker/repositories
I can`t find REGISTRY_DATA_DIR,pls help...


Reply to this email directly or view it on GitHub
#9.

At path of /var/lib/docker/
containers devicemapper graph linkgraph.db repositories-devicemapper tmp trust volumes
no repositories folder...
Any where wrong?

oh, yeah, that's the docker graph location on your host, not your registry data directory. your registry data is wherever you bindmounted it to when you started up your registry. i start my registry with a docker-compose.yml like this:

registry:
  # restart: always
  image: registry:2.1.1
  ports:
    - 5000:5000
  environment:
    REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /var/lib/registry
  volumes:
    - /opt/registry_data:/var/lib/registry

i'm tell the registry to put its data in the container at /var/lib/registry (i think this is default now, so you can probably omit the REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY line) and then i mount /opt/registry on the host as the volume which persists /var/lib/registry inside the countainer. perhaps you used another location on the host instead of /opt/registry.

if you're still not sure where you put it, you could try this:

locate v2/repositories

Thanks @burnettk
Flow your step,It`s working.
But have a new issue:
Below:

1.delete registry images(success):
> delete_docker_registry_image --image app/ctcrawler:1.0

2.Try pull this images tag in client:
>docker pull private-registry-server/app/ctcrawler:1.0
show some logs:

Pulling repository private-registry-server/app/ctcrawler
invalid character '<' looking for beginning of value

3.Try push client images tags:
>docker pull private-registry-server/app/ctcrawler:1.0
Success

4.delete again:
>docker pull private-registry-server/app/ctcrawler:1.0
show logs:

Traceback (most recent call last):
File "/usr/local/bin/delete_docker_registry_image", line 336, in
main()
File "/usr/local/bin/delete_docker_registry_image", line 325, in main
cleaner.delete_repository_tag(image, tag, force=args.force)
File "/usr/local/bin/delete_docker_registry_image", line 213, in delete_repository_tag
if self._layer_in_same_repo(repo, tag, layer):
File "/usr/local/bin/delete_docker_registry_image", line 165, in _layer_in_same_repo
layers = self._get_layers_from_blob(manifest)
File "/usr/local/bin/delete_docker_registry_image", line 85, in _get_layers_from_blob
return get_layers_from_blob(data_path)
File "/usr/local/bin/delete_docker_registry_image", line 38, in get_layers_from_blob
with open(path, "r") as blob:
IOError: [Errno 2] No such file or directory: '/root/registry/registry/docker/registry/v2/blobs/sha256/f6/f6f965fc3e8e8e99b4ce90cd1a3f0ee96223e40451112a05c24112305e6212be/data'

What`s wrong?

i think you're experiencing the issue described in #10. if this is true, i
just fixed it, so it would be helpful if you could install the new version,
try again, and confirm that it's working now.

On Mon, Mar 7, 2016 at 12:42 AM, David guo notifications@github.com wrote:

Thanks @burnettk https://github.com/burnettk
Flow your step,Its working.
But have a new issue:
Below:
1.delete registry images(success):

delete_docker_registry_image --image app/ctcrawler:1.0
2.Try pull this images tag in client:
docker pull private-registry-server/app/ctcrawler:1.0
show some logs:
Pulling repository private-registry-server/app/ctcrawler
invalid character '<' looking for beginning of value

3.Try push client images tags:
docker pull private-registry-server/app/ctcrawler:1.0`
Success
4.delete again:
docker pull private-registry-server/app/ctcrawler:1.0
show logs:

Traceback (most recent call last):
File "/usr/local/bin/delete_docker_registry_image", line 336, in
main()
File "/usr/local/bin/delete_docker_registry_image", line 325, in main
cleaner.delete_repository_tag(image, tag, force=args.force)
File "/usr/local/bin/delete_docker_registry_image", line 213, in
delete_repository_tag
if self._layer_in_same_repo(repo, tag, layer):
File "/usr/local/bin/delete_docker_registry_image", line 165, in
_layer_in_same_repo
layers = self._get_layers_from_blob(manifest)
File "/usr/local/bin/delete_docker_registry_image", line 85, in
_get_layers_from_blob
return get_layers_from_blob(data_path)
File "/usr/local/bin/delete_docker_registry_image", line 38, in
get_layers_from_blob
with open(path, "r") as blob:
IOError: [Errno 2] No such file or directory:
'/root/registry/registry/docker/registry/v2/blobs/sha256/f6/f6f965fc3e8e8e99b4ce90cd1a3f0ee96223e40451112a05c24112305e6212be/data'

What`a wrong?


Reply to this email directly or view it on GitHub
#9 (comment)
.

Okay...will trying.
Thanks @burnettk

Let me know if you have ongoing issues. Thanks!