mirror of
https://github.com/yeasy/docker_practice.git
synced 2024-12-24 22:18:54 +00:00
Update local repo usage, add a batch script to upload local images
This commit is contained in:
parent
86f8095149
commit
a9825f93e9
45
_local/push_images.sh
Normal file
45
_local/push_images.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script will upload the local images to a registry server ($registry is the default value).
|
||||
# Author: yeasy@github
|
||||
# Created:2014-09-23
|
||||
|
||||
#The registry server address where you want push the images into
|
||||
registry=127.0.0.1:5000
|
||||
|
||||
### DO NOT MODIFY THE FOLLOWING PART, UNLESS YOU KNOW WHAT IT MEANS ###
|
||||
echo_r () {
|
||||
[ $# -ne 1 ] && return 0
|
||||
echo -e "\033[31m$1\033[0m"
|
||||
}
|
||||
echo_g () {
|
||||
[ $# -ne 1 ] && return 0
|
||||
echo -e "\033[32m$1\033[0m"
|
||||
}
|
||||
echo_y () {
|
||||
[ $# -ne 1 ] && return 0
|
||||
echo -e "\033[33m$1\033[0m"
|
||||
}
|
||||
echo_b () {
|
||||
[ $# -ne 1 ] && return 0
|
||||
echo -e "\033[34m$1\033[0m"
|
||||
}
|
||||
|
||||
usage() {
|
||||
sudo docker images
|
||||
echo "Usage: $0 registry1:tag1 [registry2:tag2...]"
|
||||
}
|
||||
|
||||
[ $# -lt 1 ] && usage && exit
|
||||
|
||||
echo_b "The registry server is $registry"
|
||||
|
||||
|
||||
for image in "$@"
|
||||
do
|
||||
echo_b "Uploading $image..."
|
||||
sudo docker tag $image $registry/$image
|
||||
sudo docker push $registry/$image
|
||||
sudo docker rmi $registry/$image
|
||||
echo_g "Done"
|
||||
done
|
@ -111,7 +111,7 @@ $ curl http://192.168.7.26:5000/v1/search
|
||||
```
|
||||
这里可以看到`{"description": "", "name": "library/test"}`,表明镜像已经被成功上传了。
|
||||
|
||||
现在可以到另外一台机器去下载这个镜像
|
||||
现在可以到另外一台机器去下载这个镜像。
|
||||
```
|
||||
$ sudo docker pull 192.168.7.26:5000/test
|
||||
Pulling repository 192.168.7.26:5000/test
|
||||
@ -125,3 +125,34 @@ $ sudo docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
||||
|
||||
可以使用[这个脚本](https://github.com/yeasy/docker_practice/blob/master/_local/push_images.sh)批量上传本地的镜像到注册服务器中,默认是本地注册服务器`127.0.0.1:5000`。例如:
|
||||
```
|
||||
$ ./push_images.sh ubuntu:latest centos:centos7
|
||||
The registry server is 127.0.0.1
|
||||
Uploading ubuntu:latest...
|
||||
The push refers to a repository [127.0.0.1:5000/ubuntu] (len: 1)
|
||||
Sending image list
|
||||
Pushing repository 127.0.0.1:5000/ubuntu (1 tags)
|
||||
Image 511136ea3c5a already pushed, skipping
|
||||
Image bfb8b5a2ad34 already pushed, skipping
|
||||
Image c1f3bdbd8355 already pushed, skipping
|
||||
Image 897578f527ae already pushed, skipping
|
||||
Image 9387bcc9826e already pushed, skipping
|
||||
Image 809ed259f845 already pushed, skipping
|
||||
Image 96864a7d2df3 already pushed, skipping
|
||||
Pushing tag for rev [96864a7d2df3] on {http://127.0.0.1:5000/v1/repositories/ubuntu/tags/latest}
|
||||
Untagged: 127.0.0.1:5000/ubuntu:latest
|
||||
Done
|
||||
Uploading centos:centos7...
|
||||
The push refers to a repository [127.0.0.1:5000/centos] (len: 1)
|
||||
Sending image list
|
||||
Pushing repository 127.0.0.1:5000/centos (1 tags)
|
||||
Image 511136ea3c5a already pushed, skipping
|
||||
34e94e67e63a: Image successfully pushed
|
||||
70214e5d0a90: Image successfully pushed
|
||||
Pushing tag for rev [70214e5d0a90] on {http://127.0.0.1:5000/v1/repositories/centos/tags/centos7}
|
||||
Untagged: 127.0.0.1:5000/centos:centos7
|
||||
Done
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user