Tune Docker Registry (continue)
- 1. Install docker registry
- 2. Read image from docker.io, rename and push it to own private registry.
- 3. Explore Registry API - read image catalog, hash and layers.
- 4. Connect to Docker API with Docker.Registry.DotNet
1. Install docker registry
# sudo docker run -d -p 5000:5000 --restart always --name registry registry:2 # sudo docker ps
2. Read image from docker.io, rename and push it to own private registry.
# sudo docker pull alexev275/coinbase # sudo docker image ls -a # sudo docker image tag alexev275/coinbase:latest localhost:5000/coinbase:latest # sudo docker push localhost:5000/coinbase:latest
3. Explore Registry API - read image catalog, hash and layers.
# sudo curl -v http://localhost:5000/v2/_catalog # sudo curl -v http://localhost:5000/v2/coinbase/tags/list # sudo curl -v http://localhost:5000/v2/coinbase/manifests/latest
4. Connect to Docker API with Docker.Registry.DotNet
Full code uploaded to https://github.com/Alex-1347/DockerRegistryWrapper.
1: Sub Main(args As String())
2: 'prepare password
3: 'Console.Write("pass to be encrypted>")
4: 'Dim Pass1 = Console.ReadLine
5: 'Console.Write("encrypted string>")
6: 'Dim Pass2 = Console.ReadLine
7: 'Console.Write(EncryptString(Pass1, Pass2))
8: 'End
9: Console.Write("Password>")
10: Dim RegistryConfig = New RegistryClientConfiguration(My.Resources.URL)
11: Dim AU As AuthenticationProvider = New PasswordOAuthAuthenticationProvider(My.Resources.Login, DecryptString(My.Resources.Pass, ReadPassword()))
12: Dim Registry As Registry.IRegistryClient
13: Try
14: Registry = RegistryConfig.CreateClient(AU)
15: Catch ex As Exception
16: Console.WriteLine(ex.Message)
17: End Try
18: Dim Catalog As Models.Catalog = Registry.Catalog.GetCatalogAsync().Result
19: Catalog.Repositories.ToList.ForEach(Sub(X)
20: Dim Manifest As Models.GetImageManifestResult = Registry.Manifest.GetManifestAsync(X, "latest").Result
21: Console.WriteLine($"{String.Format("{0,-20}", X)} {Manifest.DockerContentDigest}")
22: End Sub
23: )
24: Console.ReadLine()
25: End Sub
5. Continue reading - Protect Docker Registry by Nginx.
Comments (
)
Link to this page:
http://www.vb-net.com/DockerRegistry2/Index.htm
|