You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First we'll test that the registry image is working correctly, by running it without any special configuration:
28
27
```
@@ -41,7 +40,7 @@ $ sudo docker pull hello-world
41
40
42
41
If a tag isn't specified, then the default `latest` is used. If a registry hostname isn't specified then the default `docker.io` for Docker Hub is used. If you want to use images with any other registry, you need to explicitly specify the hostname - the default is always Docker Hub, you can't change to a different default registry.
43
42
44
-
With a local registry, the hostname and the custom port used by the registry is the full registry address, e.g. `<hostname>:5000`.
43
+
With a local registry, the hostname and the custom port used by the registry is the full registry address, e.g. `localhost:5000`.
45
44
```
46
45
$ hostname
47
46
```
@@ -50,27 +49,27 @@ $ hostname
50
49
51
50
Docker uses the hostname from the full image name to determine which registry to use. We can build images and include the local registry hostname in the image tag, or use the `docker tag` command to add a new tag to an existing image.
52
51
53
-
These commands pull a public image from Docker Hub, tag it for use in the private registry with the full name `<hostname>:5000/hello-world`, and then push it to the registry:
52
+
These commands pull a public image from Docker Hub, tag it for use in the private registry with the full name `localhost:5000/hello-world`, and then push it to the registry:
54
53
55
54
```
56
-
$ sudo docker tag hello-world <hostname>:5000/hello-world
57
-
$ sudo docker push <hostname>:5000/hello-world
55
+
$ sudo docker tag hello-world localhost:5000/hello-world
56
+
$ sudo docker push localhost:5000/hello-world
58
57
```
59
58
60
59
When you push the image to your local registry, you'll see similar output to when you push a public image to the Hub:
61
60
62
61
```
63
-
The push refers to a repository [<hostname>:5000/hello-world]
62
+
The push refers to a repository [localhost:5000/hello-world]
On the local machine, you can remove the new image tag and the original image, and pull it again from the local registry to verify it was correctly stored:
70
69
```
71
-
$ sudo docker rmi <hostname>:5000/hello-world
70
+
$ sudo docker rmi localhost:5000/hello-world
72
71
$ sudo docker rmi hello-world
73
-
$ sudo docker pull <hostname>:5000/hello-world
72
+
$ sudo docker pull localhost:5000/hello-world
74
73
```
75
74
That exercise shows the registry works correctly, but at the moment it's not very useful because all the image data is stored in the container's writable storage area, which will be lost when the container is removed. To store the data outside of the container, we need to mount a host directory when we start the container.
76
75
@@ -92,8 +91,8 @@ registry
92
91
```
93
92
Tag and push the container with the new IP address of the registry.
94
93
```
95
-
docker tag hello-world <hostname>:5000/hello-world
96
-
docker push <hostname>:5000/hellow-world
94
+
docker tag hello-world localhost:5000/hello-world
95
+
docker push localhost:5000/hellow-world
97
96
```
98
97
Repeating the previous `docker push` command uploads an image to the registry container, and the layers will be stored in the container's `/var/lib/registry` directory, which is actually mapped to the `$(pwd)/registry-data` directory on you local machine. The `tree` command will show the directory structure the registry server uses:
Copy file name to clipboardExpand all lines: registry/part-2.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ State or Province Name (full name) [Some-State]:
28
28
Locality Name (eg, city) []:
29
29
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Docker
30
30
Organizational Unit Name (eg, section) []:
31
-
Common Name (e.g. server FQDN or YOUR name) []:<hostname>
31
+
Common Name (e.g. server FQDN or YOUR name) []:localhost
32
32
Email Address []:
33
33
```
34
34
If you are running the registry locally, be sure to use your host name as the CN.
@@ -82,8 +82,8 @@ We'll let Docker assign a random IP address to this container, because we'll be
82
82
83
83
We're ready to push an image into our secure registry.
84
84
```
85
-
$ docker push <hostname>:5000/hello-world
86
-
$ docker pull <hostname>:5000/hello-world
85
+
$ docker push localhost:5000/hello-world
86
+
$ docker pull localhost:5000/hello-world
87
87
```
88
88
We can go one step further with the open-source registry server, and add basic authentication - so we can require users to securely log in to push and pull images.
0 commit comments