Docker image 镜像介绍
操作镜像
使用 docker 命令行操作 docker 镜像
获取镜像
使用「docker pull +镜像名称」从网络上下载image镜像
core@localhost ~ $ docker pull
Usage: docker pull NAME[:TAG]
Pull an image or a repository from the registry
core@localhost ~/php $ docker pull ubuntu
#pull +镜像的名称会下载该镜像集的laste tag的镜像
Pulling repository ubuntu
2185fd50e2ca: Pulling dependent layers
9cbaf023786c: Pulling dependent layers
3db9c44f4520: Pulling dependent layers
a9561eb1b190: Pulling dependent layers
195eb90b5349: Pulling dependent layers
463ff6be4238: Pulling dependent layers
c5881f11ded9: Pulling dependent layers
511136ea3c5a: Download complete
97fd97495e49: Downloading [=====> ] 6.868 MB/67.5 MB 10m20s
.....
core@localhost ~/php $ docker pull ubuntu:14.04
#表示下载该镜像集中14.04 tag的镜像
core@localhost ~/php $ docker pull dl.dockerpool.com:5000/alexeiled/docker-oracle-xe-11g
#下载其它非官方仓库中的镜像,一般站点会给出具体的 pull 命令
Pulling repository dl.dockerpool.com:5000/alexeiled/docker-oracle-xe-11g
ba16d5d5e1aa: Pulling image (latest) from dl.dockerpool.com:5000/alexeiled/docker-oracle-xe-11g, endpoint: http://dl.dockerpool.com:5000ba16d5d5e1aa: Download complete
8dbd9e392a96: Download complete
#这一串数字是表示文件系统的层次,docker 的镜像和容器就是这一层一层的文件系统组成的
215be6e94fbb: Download complete
ef2887b77b73: Download complete
97774de1565b: Download complete
c6a02636680f: Download complete
2ae911074081: Download complete
e1787c817b10: Download complete
5e312dc5fae8: Download complete
cb35ce95b58c: Download complete
5f0e28679c8e: Download complete
...
列出镜像
使用「docker images」列出本地宿主主机上拥有的image镜像
core@localhost ~ $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
base/163 latest 468d347c06bc 28 hours ago 249.1 MB
test/supervisord latest 468d347c06bc 28 hours ago 249.1 MB
ubuntu 14.04 1357f421be38 4 days ago 192.7 MB
dl.dockerpool.com:5000/ubuntu 14.04 1357f421be38 4 days ago 192.7 MB
dl.dockerpool.com:5000/mysql 5.7 e95cbb9f48ea 6 days ago 258.6 MB
mysql 5.7 e95cbb9f48ea 6 days ago 258.6 MB
mysql latest 9a09222edf60 6 days ago 235.6 MB
tutum/lamp latest 4b32789c7d66 5 weeks ago 469.8 MB
tutum/tomcat 8.0 866eb07a675e 6 weeks ago 539.4 MB
tutum/tomcat latest 02e84f04100e 6 weeks ago 539.4 MB
dl.dockerpool.com:5000/alexeiled/docker-oracle-xe-11g latest ba16d5d5e1aa 7 months ago 2.388 GB
此处共同拥有5列。分别表示镜像的名称、镜像的tag标记、镜像的唯一 image id、创建时间、大小
创建镜像
创建镜像的方法有 2 种:
1. 从文件系统导入
眼下可用的文件系统主要是openvz的模板
比方:下载了一个ubuntu14.04的镜像 cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04 然后用docker images看下:
core@localhost ~ $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 05ac7c0b9383 17 seconds ago 215.5 MB
就多了一个我们的ubuntu镜像
2. 从 dockerfile 创建
dockerfile的内容后面章节具体介绍
3. 从现有的容器 commit 提交到一个新的 image
core@localhost ~ $ docker commit
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Create a new image from a container's changes
-a, --author="" Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
#填写作者信息
-m, --message="" Commit message
#填写提交信息
-p, --pause=true Pause container during commit
#假设容器还在执行,先暂停容器
core@localhost ~ $ docker run -ti ubuntu:14.04 /bin/bash
#创建一个仅仅有bash程序的容器
root@a925cb40b3f0:/# touch test
#在容器中建立一个文件
root@a925cb40b3f0:/# exit
#退出
exit
core@localhost ~ $ docker commit a92 for_test
#将刚才的容器提交为一个叫 for_test 的镜像,这里我们使用容器的 id 来指定我们要提交的容器。也能够使用容器的名字。他们都是唯一的
9e9c814023bcffc3e67e892a235afe61b02f66a947d2747f724bd317dda02f27
#返回新镜像的 id
core@localhost ~ $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
for_test latest 9e9c814023bc 4 seconds ago 192.7 MB
删除镜像
使用「docker rmi + 镜像 id」删除镜像,当还有容器使用该镜像的时候是无法删除的。
core@localhost ~ $ docker rmi
Usage: docker rmi IMAGE [IMAGE...]
Remove one or more images
-f, --force=false Force removal of the image
--no-prune=false Do not delete untagged parents
core@localhost ~ $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
for_test latest 60734a0ee3d6 3 seconds ago 192.7 MB
base/163 latest 468d347c06bc 29 hours ago 249.1 MB
test/supervisord latest 468d347c06bc 29 hours ago 249.1 MB
ubuntu 14.04 1357f421be38 4 days ago 192.7 MB
dl.dockerpool.com:5000/ubuntu 14.04 1357f421be38 4 days ago 192.7 MB
dl.dockerpool.com:5000/mysql 5.7 e95cbb9f48ea 6 days ago 258.6 MB
mysql 5.7 e95cbb9f48ea 6 days ago 258.6 MB
mysql latest 9a09222edf60 6 days ago 235.6 MB
tutum/lamp latest 4b32789c7d66 5 weeks ago 469.8 MB
tutum/tomcat 8.0 866eb07a675e 6 weeks ago 539.4 MB
tutum/tomcat latest 02e84f04100e 6 weeks ago 539.4 MB
dl.dockerpool.com:5000/alexeiled/docker-oracle-xe-11g latest ba16d5d5e1aa 7 months ago 2.388 GB
core@localhost ~ $ docker rmi 9a0
#当我们删除镜像 9a0 即 mysql:latest 镜像时。它删除了这个镜像所附带的全部aufs层
Untagged: mysql:latest
Deleted: 9a09222edf600a03ea48bd23cfa363841e45a8715237e3a58cb0167f0e8bad54
Deleted: 4daeda4ad839a152a3b649672bd5135977d7f81866d3bc0e16d0af3f65cc8af6
Deleted: cf07a411bf0883bd632940e8108dac49c64456a47f7390507de5685bbd6daf85
Deleted: 4f513746df18b222a07bb8d76d4b6d29752ce5dcb69bfad0ce92e6c1449a3821
Deleted: 228ecd435c8a29d25b77999036701a27f2d67874c915bb8eb9fb175b1f98aa60
Deleted: 37e4b3932afa186924a09eab332bc8ebec3aac8bac074314ed9a2d1e94547f50
Deleted: 898883ccfcee705e440547e30e240cb025c12410d7c9e4d2bcb11973ba075975
Deleted: 0a09ddcf99b7fd8fcb3525c41b54696038ecf13677f4459f1c98c742ffa60ab2
Deleted: 35bc8591e39be5089265a093e234d13a4b155a01d2ab9e8904eafa81664fb597
Deleted: 857e856e4481d59ee88a4cdedd9aaf855666bd494fa38506e6788361c0af4cda
core@localhost ~ $ docker ps
#使用 -ps 參数能够看到眼下有上个容器在执行。当中一个容器是以tutum/lamp:laste镜像启动的
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9cb2e45814e0 tutum/lamp:latest "/run.sh" 4 hours ago Up 4 hours 0.0.0.0:3306->3306/tcp, 0.0.0.0:8080->80/tcp loving_feynman
e3c136d76b44 tutum/tomcat:8.0 "/run.sh" 6 hours ago Up 6 hours 0.0.0.0:80->8080/tcp tomcat001
fe9e65aaf58c dl.dockerpool.com:5000/mysql:5.7 "/entrypoint.sh mysq 6 hours ago Up 6 hours 3306/tcp db001,tomcat001/tomysql
core@localhost ~ $ docker rmi 4b3
#当我们试图删除tutum/lamp:laste 镜像时,提示我们眼下还有容器在使用该镜像,无法删除。如需删除则须要停止容器并用-f 參数删除镜像
Error response from daemon: Conflict, cannot delete 4b32789c7d66 because the running container 9cb2e45814e0 is using it (docker untagged the image), stop it and use -f to force
2014/10/15 08:23:59 Error: failed to remove one or more images
搜寻镜像
使用「docker search + keyword」搜索共享的镜像。默认搜索官方仓库的镜像,搜索私有仓库的语法在私有仓库章节具体介绍。
core@localhost ~ $ docker search
Usage: docker search TERM
Search the Docker Hub for images
--automated=false Only show automated builds
--no-trunc=false Don't truncate output
-s, --stars=0 Only displays with at least x stars
#一般使用不带參数的搜寻就可以,比方要搜寻mysqlkeyword的 image
core@localhost ~ $ docker search mysql
#返回的信息有5列。分别代表镜像集名称,镜像的描写叙述。被收藏的次数,时候属于官方出品,时候支持自己主动创建
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relati... 193 [OK]
tutum/mysql MySQL Server image - listens in port 3306.... 69 [OK]
orchardup/mysql 36 [OK]
tutum/lamp LAMP image - Apache listens in port 80, an... 30 [OK]
tutum/wordpress Wordpress Docker image - listens in port 8... 24 [OK]
paintedfox/mariadb A docker image for running MariaDB 5.5, a ... 19 [OK]
dockerfile/mysql Trusted automated MySQL (http://dev.mysql.... 11 [OK]
anapsix/gitlab-ci GitLab-CI Continuous Integration in Docker... 11 [OK]
centurylink/drupal Drupal docker image without a DB included ... 10 [OK]
google/mysql MySQL server for Google Compute Engine 10 [OK]
stenote/docker-lemp MySQL 5.6、PHP 5.5、Nginx、Memcache 9 [OK]
上传镜像
使用「docker push +keyword 」上传镜像到官方仓库,上传私有仓库的语法在私有仓库章节具体介绍。
core@localhost ~ $ docker push
Usage: docker push NAME[:TAG]
Push an image or a repository to the registry
core@localhost ~ $ docker push base/163
The push refers to a repository [base/163] (len: 1)
Sending image list
Please login prior to push:
Username: waitfish
Password:
Email: xxx@xxx.com
第一次上传须要填写在dockerhub注冊的帐号信息
很多其它内容请关注 http://www.dockerpool.com
Docker image 镜像介绍的更多相关文章
- Docker 镜像介绍和命令
目录 是什么 UnionFS(联合文件系统) Docker镜像加载原理 分层的镜像 为什么 Docker 镜像要采用这种分层结构呢 特点 Docker镜像commit操作补充 案例演示 1.从Hub上 ...
- Docker:镜像操作和容器操作
镜像操作 列出镜像: $ sudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE hello-world latest 0a6b ...
- 从零开始构建docker基础镜像
段子 今年基本已经结束了,我问了很多朋友今年挣钱了没?大多朋友都有挣,而且挣得五花八门:有挣个屁的,有挣个锤子的,有挣个毛的,更有甚者挣个妹的,奢侈之极!最恐怖的是挣个鬼的!有的还可以,挣个球,下午我 ...
- Docker 基础 : 镜像
目录 获取镜像 查看镜像信息 搜索镜像 删除镜像 创建镜像 导出和导入镜像 上传镜像 总结 镜像是 Docker 的三大核心概念之一.Docker 运行容器前需要本地存在对应的镜像,如果本地没有对应的 ...
- 微服务架构 - 搭建docker本地镜像仓库并提供权限校验及UI界面
搭建docker本地镜像仓库并提供权限校验及UI界面 docker本地镜像仓库的作用跟maven私服差不多,特别是公司级或者是小组级开发好的docker仓库可以上传到本地镜像仓库中,需要用时,直接从本 ...
- Docker: 基础介绍 [一]
一.Docker介绍 Docker是Docker.lnc公司开源的一个基于LXC技术之上构建的Container容器引擎,源代码托管在Github上,基于Go语言并遵从Apache2.0协议开源 Do ...
- Docker for .Net Developers(part1:Docker基本概念介绍)
一.什么是Docker 目前,.Net 社区中很可能会用到的两个词是“微服务”和“Docker”. 这两个主题都非常引人注目,并为开发人员和架构师带来兴奋之情. 在这个新系列的博客文章中,我把自己最近 ...
- docker 拷贝镜像文件
1.概述 我们制作好镜像后,有时需要将镜像复制到另一台服务器使用. 能达到以上目的有两种方式,一种是上传镜像到仓库中(本地或公共仓库),但是另一台服务器很肯能只是与当前服务器局域网想通而没有公网的,所 ...
- Docker 创建镜像、修改、上传镜像
Docker 创建镜像.修改.上传镜像 –创建镜像有很多方法,用户可以从 Docker Hub 获取已有镜像并更新,也可以利用本地文件系统创建一个. 一.创建镜像 创建镜像有很多方法,用户可以从 Do ...
随机推荐
- Enabling Active Directory Authentication for VMWare Server running on Linux《转载》
Enabling Active Directory Authentication for VMWare Server running on Linux Version 0.2 - Adam Breid ...
- [ASP.NET] 檔案讀寫權限問題
今天遇到一個問題,環境如下: IIS Server: Server 2008 R2 沒加域 File Server: Server 2003 加域 當我的Web程序需要把位於File Server的一 ...
- 获取Excel表中各个Sheet的方法
获取Excel表中各个Sheet的方法 private void simpleButton2_Click(object sender, EventArgs e) { OfdBOM.Filter = & ...
- C# 创建验证码图片
using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; us ...
- 用sp_change_users_login消除Sql Server的孤立用户
异常详细信息: System.Data.SqlClient.SqlException: 拒绝了对对象 'zwj_EnterpriseActivities' (数据库 'Ntours',架构 'dbo' ...
- MVC与三层架构的关系
- 用excel做一幅像素画
开发背景 看到网上有人发教程,如何通过在excel里设置单元格颜色画一幅画,感觉手工做太复杂,就打算用程序实现一个. 开发运行环境 python 2.7 PIL xlsxwriter 用法 pytho ...
- <c:if>标签
<c:if>的用途就和我们一般在程序中用的if一样. 语法 语法1:没有本体内容(body) <c:if test="testCondition" var=&qu ...
- eclipse 将文件夹作为sourcefolder
文件夹---右键
- Bootstrap 实例 - 模态框(Modal)插件
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...