docker 仓库
仓库介绍
仓库是集中存放镜像的地方。
Docker Hub 是docker官方维护了一个公共仓库,大部分需求都可以在Docker Hub上直接下载镜像
拉取镜像
可以通过docker search
和docker pull
命令来拉取镜像
1 2 3 4 5 6 7 8 9 10 11 |
[root@xs_test01 docker]# docker search redis NAME(名字) DESCRIPTION(描述) STARS(受关注度) OFFICIAL(是否官方创建) AUTOMATED(是否自动创建) redis Redis is an open source key-value store that… 4879 [OK] bitnami/redis Bitnami Redis Docker Image 70 [OK] sameersbn/redis 64 [OK] tenstartups/redis-commander 32 [OK] hypriot/rpi-redis Raspberry Pi compatible redis image 30 joshula/redis-sentinel A container for Redis Sentinel 21 kubeguide/redis-master redis-master with "Hello World!" 19 kubeguide/guestbook-redis-slave Guestbook redis slave 16 webhippie/redis Docker images for redis 8 [OK] |
---|
1 2 3 4 5 |
[root@xs_test01 docker]# docker pull redis Using default tag: latest latest: Pulling from library/redis Digest: sha256:e55dff3a21a0e7ba25e91925ed0d926d959dac09f9099fd1bcc919263305f1e4 Status: Image is up to date for redis:latest |
---|
推送镜像
用户可以通过docker push
命令来将自己的镜像推送到Docker Hub
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
登陆 #docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: devilf Password: Login Succeeded 使用Docker Hub账户的用户名打一个标签 #docker tag ubuntu:17.04 devilf/ubuntu:17.04 查看# docker images 推送 #docker push devilf/ubuntu:17.04 The push refers to repository [docker.io/devilf/ubuntu] 3ff70ce53dac: Pushed b8e5935ae7cc: Pushed ba76b502dc9b: Pushed 803030df23c1: Pushed db8686e0ca43: Pushed 17.04: digest: sha256:213e05583a7cb8756a3f998e6dd65204ddb6b4c128e2175dcdf174cdf1877459 size: 1357 搜索 #docker search devilf NAME DESCRIPTION STARS OFFICIAL AUTOMATED devilflake/get-started 0 |
---|
私有仓库
安装docker-registry
1 2 3 4 5 6 7 8 9 10 11 12 13 |
第一次启动时报错: [root@xs_test01 docker]# docker run -d -p 5000:5000 --restart=always --name registry registry 36ebd0311366dc9ba3faa8afa42c9e796a1f4c72f5bd870c40404207ef2d01c5 docker: Error response from daemon: driver failed programming external connectivity on endpoint registry (f4e440a237fa6fc0b6e727d9a4dacf5140f02abc330a83e1884df81f5e1c4f93): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 5000 -j DNAT --to-destination 172.17.0.3:5000 ! -i docker0: iptables: No chain/target/match by that name. (exit status 1)). 原因是因为centos7上的firewalld防火墙给关闭了,使用的是iptables,手动打开firewall即可正常启动。 第二次启动正常: [root@xs_test01 docker]# docker run -d -p 5000:5000 --restart=always --name registry registry 01bec932a1107403ad929633941bbf654bc89d74f73df68ec2f7a49a9f031465 [root@xs_test01 docker]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 01bec932a110 registry "/entrypoint.sh /etc…" 4 seconds ago Up 2 seconds 0.0.0.0:5000->5000/tcp registry 1cd1fadb254b ubuntu:17.04 "/bin/sh -c 'while t…" 3 hours ago Up 3 hours kind_wilson |
---|
默认使用官方的registry镜像来启动私有仓库,会被放到/var/lib/registry
目录下,我们可以通过-v
参数来将镜像文件存放在本地的指定路径。
1 2 3 4 5 6 |
[root@xs_test01 docker]# docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry registry eab05e17db69f8fc728dec4dd579d7e7e523b5ac64eee83302ba2c8965d25dfc [root@xs_test01 docker]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eab05e17db69 registry "/entrypoint.sh /etc…" 4 seconds ago Up 4 seconds 0.0.0.0:5000->5000/tcp hopeful_bose 1cd1fadb254b ubuntu:17.04 "/bin/sh -c 'while t…" 3 hours ago Up 3 hours kind_wilson |
---|
本地是没有/opt/data/registry
这个目录的,使用-v
参数会自动创建目录
在私有仓库上传、搜索、下载镜像
创建好私有仓库后,我们使用docker tag
来标记一个镜像,然后推送到仓库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
打标签 [root@xs_test01 registry]# docker tag ubuntu:14.04 127.0.0.1:5000/ubuntu:14.04 查看打完标签后的镜像 [root@xs_test01 registry]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu.tar latest a56d3f7377d4 3 hours ago 80MB openvz/ubuntu 14.04 4fb9933d51b0 5 hours ago 215MB ubuntu 14.04 a35e70164dfb 7 days ago 222MB 127.0.0.1:5000/ubuntu 14.04 a35e70164dfb 7 days ago 222MB devilf/ubuntu 17.04 fe1cc5b91830 2 months ago 95.6MB ubuntu 17.04 fe1cc5b91830 2 months ago 95.6MB hello-world latest f2a91732366c 3 months ago 1.85kB 将做好标签的镜像推送到私有仓库中 [root@xs_test01 registry]# docker push 127.0.0.1:5000/ubuntu:14.04 The push refers to repository [127.0.0.1:5000/ubuntu] 65262d4f5516: Pushed dd420adea0d3: Pushed 3abb69fb15dc: Pushed e95051d9cb9b: Pushed 92fb50b4d953: Pushed 14.04: digest: sha256:0661e2dbc6072eadfd48c0c972681ffc11ca8ea5d0a9f5f4227df7d653f649fd size: 1359 使用curl命令查看仓库中的镜像 [root@xs_test01 registry]# curl 127.0.0.1:5000/v2/_catalog {"repositories":["ubuntu"]} 删除已有的镜像 [root@xs_test01 registry]# docker image rm 127.0.0.1:5000/ubuntu:14.04 Untagged: 127.0.0.1:5000/ubuntu:14.04 Untagged: 127.0.0.1:5000/ubuntu@sha256:0661e2dbc6072eadfd48c0c972681ffc11ca8ea5d0a9f5f4227df7d653f649fd [root@xs_test01 registry]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu.tar latest a56d3f7377d4 3 hours ago 80MB openvz/ubuntu 14.04 4fb9933d51b0 5 hours ago 215MB ubuntu 14.04 a35e70164dfb 7 days ago 222MB entrypoint latest 10c7252261f8 8 days ago 4.82MB myip latest 7f77fc2f30b7 8 days ago 307MB nginx v3 7386045ee352 9 days ago 109MB nginx v2 ada0bc75fda7 9 days ago 109MB nginx latest e548f1a579cf 3 weeks ago 109MB redis latest 33c26d72bd74 3 weeks ago 107MB registry latest d1fd7d86a825 2 months ago 33.3MB alpine 3.4 c7fc7faf8c28 2 months ago 4.82MB centos latest ff426288ea90 2 months ago 207MB devilf/ubuntu 17.04 fe1cc5b91830 2 months ago 95.6MB ubuntu 17.04 fe1cc5b91830 2 months ago 95.6MB hello-world latest f2a91732366c 3 months ago 1.85kB 可以看出之前打好标签的镜像确实已经删除 从私有仓库中拉取镜像 [root@xs_test01 registry]# docker pull 127.0.0.1:5000/ubuntu:14.04 14.04: Pulling from ubuntu Digest: sha256:0661e2dbc6072eadfd48c0c972681ffc11ca8ea5d0a9f5f4227df7d653f649fd Status: Downloaded newer image for 127.0.0.1:5000/ubuntu:14.04 [root@xs_test01 registry]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu.tar latest a56d3f7377d4 3 hours ago 80MB openvz/ubuntu 14.04 4fb9933d51b0 5 hours ago 215MB 127.0.0.1:5000/ubuntu 14.04 a35e70164dfb 7 days ago 222MB ubuntu 14.04 a35e70164dfb 7 days ago 222MB entrypoint latest 10c7252261f8 8 days ago 4.82MB myip latest 7f77fc2f30b7 8 days ago 307MB nginx v3 7386045ee352 9 days ago 109MB nginx v2 ada0bc75fda7 9 days ago 109MB nginx latest e548f1a579cf 3 weeks ago 109MB redis latest 33c26d72bd74 3 weeks ago 107MB registry latest d1fd7d86a825 2 months ago 33.3MB alpine 3.4 c7fc7faf8c28 2 months ago 4.82MB centos latest ff426288ea90 2 months ago 207MB devilf/ubuntu 17.04 fe1cc5b91830 2 months ago 95.6MB ubuntu 17.04 fe1cc5b91830 2 months ago 95.6MB hello-world latest f2a91732366c 3 months ago 1.85kB |
---|
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- [AWR报告]Library Hit %
- [Oracle 9i安装]Redhat 4.8的配置
- [Oracle 9i安装]Oracle软件的安装
- [AWR报告]Latch Hit %
- [Python运维]Python3.6的安装
- [Python运维]cx_Oracle模块的安装
- C#中抽象类与抽象方法的作用与实例
- C++ 基础扫盲(1)
- [Python运维]使用cx_Oracle连接Oracle(高级篇)
- [Python运维]使用Python发送邮件
- [Python运维]自动化监控Oracle表空间并发送报警
- [Python运维]自动化监控多个Oracle表空间
- c# 动态生成控件
- C# 10分钟完成百度人脸识别——入门篇
- C#开启线程的四种方式