docker创建 私有仓库

3年前 (2017-06-09) gtj docker, 云计算 0评论 已收录 263℃

docker pull registry
罗列nat表
iptables -t nat -L
docker-compose
https://www.docker.com/docker-compose
https://github.com/docker/compose

docker run -d -p 5001:5000 registry 启动docker私有仓库
默认情况下,会将仓库存放于容器内的/tmp/registry目录下,这样如果容器被删除,则存放于容器中的镜像也会丢失,所以我们一般情况下会指定本地一个目录挂载到容器内的/tmp/registry下,如下:

[root@localhost opt]# docker run -d -p 5000:5000 -v /opt/registry:/tmp/registry docker.io/registry
操作如下:
[root@docker-test ~]#
docker run -d registry
92d53997aad62c5ad8c8b1aa6b29373026ae80db97295628e6100e9f168d6b5d
[root@docker-test ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92d53997aad6 registry "/entrypoint.sh /etc/" 57 seconds ago Up 53 seconds 5000/tcp zen_nobel

传东西到仓库里

打包镜像到私有仓库里:
docker tag java 10.20.23.144:5000/test/java:v1

结果如下:
[root@docker-test ~]# docker images
10.20.23.144:5000/test/java v1 d23bdf5b1b1b 11 weeks ago 643.1 MB

从私有仓库里下载:
docker push 10.20.23.144:5000/test/java:v1
下载失败
要在docker配置文件里加上一段
vim /etc/sysconfig/docker
DOCKER_OPTS="--registry-mirror=http://aad0405c.m.daocloud.io"
ADD_REGISTRY='--add-registry 10.20.23.144:5000'
INSECURE_REGISTRY='--insecure-registry 10.20.23.144:5000'
systemctl restart docker
再次操作;
docker run -d -p 5000:5000 -v /opt/registry:/tmp/registry docker.io/registry
docker tag docker.io/elasticsearch:latest 10.20.23.144:5000/test/es
下载docker镜像:
docker push 10.20.23.144:5000/test/es:latest

在另一台机子上要用
docker pull 下载下来

docker pull 10.20.23.144:5000/test/es
Using default tag: latest
Trying to pull repository 10.20.23.144:5000/test/es ...
sha256:32c9b62c9573ec0b4d2716e96302fe01bf39b3ce226e2a0faaa0a8bc65458933: Pulling from 10.20.23.144:5000/test/es
df559435c037: Pull complete
ifconfig

eth0: flags=4163 mtu 1500
inet 10.20.23.213 netmask 255.255.255.0 broadcast 10.20.23.255
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
10.20.23.144:5000/test/es latest c90c19ac5480 13 hours ago 352.2 MB
启动镜像
[root@oldboy ~]#
docker run -it --name es 10.20.23.144:5000/test/es
[2017-04-05T12:34:59,810][INFO ][o.e.n.Node ] [] initializing ...
[2017-04-05T12:35:00,383][INFO ][o.e.e.NodeEnvironment ] [loJjJy5] using [1] data pat
成功启动了。
[root@oldboy ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68176fe0f3b9 10.20.23.144:5000/test/es "/docker-entrypoint.s" About a minute ago Up About a minute 9200/tcp, 9300/tcp es


博主

这货来去如风,什么鬼都没留下!!!

相关推荐

嗨、骚年、快来消灭0回复。

×
订阅图标按钮
Less is more!!!