Registry Image Layers are not shared
Summary
Container image layers are not shared across repositories (even publicly visible projects). Are there configuration options that can enable this? Is there a reason this is the expected/desired behavior?
Steps to reproduce
I have two publicly visible projects.
- Push an image for the first project:
$ docker push <my_gitlab>/user/project:tag
The push refers to repository [...]
6ee5b085558c: Pushed
78f25536dafc: Pushed
9c46f426bcb7: Layer already exists
tag: digest: sha256:edad5e71815c79108ddbd1d42123ee13ba2d8050ad27cfa72c531986d03ee4e7 size: 948
- Create second tag image for other repo:
$ docker tag <my_gitlab>/user/project:tag <my_gitlab>/user2/project2:tag2
- Push second tag:
$ docker push <my_gitlab>/user2/project2:tag2
The push refers to repository [...]
6ee5b085558c: Pushed
78f25536dafc: Pushed
9c46f426bcb7: Layer already exists
tag2: digest: sha256:edad5e71815c79108ddbd1d42123ee13ba2d8050ad27cfa72c531986d03ee4e7 size: 948
As you can see, the layers are pushed again and not shared across the images. This is very inefficient as transfer times for pushing and pulling can be unnecessarily very slow for large images.
What is the current bug behavior?
All layers for an image in a given repo must be pushed, even if all of the layers are already present in the container registry on Gitlab for another repo.
What is the expected correct behavior?
Layers already present in the container registry from another repo would not need to be pushed. This feature has existed in the docker registry source code for a while (see this PR).
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 2.3.7p456 Gem Version: 2.6.14 Bundler Version:1.13.7 Rake Version: 12.3.1 Redis Version: 3.2.11 Git Version: 2.16.4 Sidekiq Version:5.0.5 Go Version: unknownGitLab information Version: 10.8.4 Revision: 2268d0c Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: ... HTTP Clone URL: .../some-group/some-project.git SSH Clone URL: ssh://.../some-group/some-project.git Using LDAP: no Using Omniauth: no
GitLab Shell Version: 7.1.2 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 7.1.2 ? ... OK (7.1.2) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 2/1 ... repository is empty 3/2 ... ok 3/3 ... ok 3/4 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 3/2 ... yes 3/3 ... yes 3/4 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.3.7) Git version >= 2.9.5 ? ... yes (2.16.4) Git user has default SSH configuration? ... yes Active users: ... 3
Checking GitLab ... Finished