第一天docker入门
【01 入门】
docker 最核心为三部分组成 镜像,仓库和容器
镜像:一个只读的模板
仓库:代码仓库,镜像的集合
容器:镜像的实例化进程
我们可以这样理解 容器就是一个沙箱,docker利用容器运行和隔离应用,每个容器之间都是彼此独立的
第一次使用docker
[1]查看版本
root@SSS:/data# docker version
Client:
Version: 1.13.1
API version: 1.26
Go version: go1.7.4
Git commit: 092cba3
Built: Thu Sep 7 17:09:45 2017
OS/Arch: linux/amd64 Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Go version: go1.7.4
Git commit: 092cba3
Built: Thu Sep 7 17:09:45 2017
OS/Arch: linux/amd64
Experimental: false
docker 由客户端和服务器组成
[2]使用镜像
##查看本地镜像
root@SSS:/data# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 f975c5035748 3 weeks ago 112 MB
##这里我们有一个Ubuntu 16.04 镜像
我们还可以获取其他镜像 如果不加参数 默认会去 docker hub 里面拉取 你可以指定远程的docker源 这个很pip yum 很像
root@SSS:/data# docker pull ubuntu:15.04
15.04: Pulling from library/ubuntu
9502adfba7f1: Pull complete
4332ffb06e4b: Pull complete
2f937cc07b5f: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:2fb27e433b3ecccea2a14e794875b086711f5d49953ef173d8a03e8707f1510f
Status: Downloaded newer image for ubuntu:15.04
root@SSS:/data# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 f975c5035748 3 weeks ago 112 MB
ubuntu 15.04 d1b55fd07600 2 years ago 131 MB
这里我们就有两个镜像啦
当然我们可以执行远程的源
root@SSS:/data# docker pull hub.c.163.com/public/ubuntu:14.04
14.04: Pulling from public/ubuntu
f4ab0b34ba6a: Pull complete
2f0787dc0bfe: Pull complete
54c427d77362: Pull complete
51e87d5424ff: Pull complete
5dfa314e7290: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:ffc2fc66f8e0bfa4b417b817054d3ebec130c8db44342b8fa394e25779633257
Status: Downloaded newer image for hub.c.163.com/public/ubuntu:14.04
root@SSS:/data#
这里演示的是从163的源 下载镜像
docket tag 可以一个docker镜像增加一个标签 实际上还是一个镜像 但是新建一个快捷名称
root@SSS:/data# docker tag ubuntu:15.04 test:15.04
root@SSS:/data# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 f975c5035748 3 weeks ago 112 MB
hub.c.163.com/public/ubuntu 14.04 2fe5c4bba1f9 2 years ago 237 MB
ubuntu 15.04 d1b55fd07600 2 years ago 131 MB
test 15.04 d1b55fd07600 2 years ago 131 MB
docker inspect 可以列出镜像的详细信息
root@SSS:/data# docker inspect ubuntu:15.04
[
{
"Id": "sha256:d1b55fd07600b2e26d667434f414beee12b0771dfd4a2c7b5ed6f2fc9e683b43",
"RepoTags": [
"test:15.04",
"ubuntu:15.04"
],
"RepoDigests": [
"ubuntu@sha256:2fb27e433b3ecccea2a14e794875b086711f5d49953ef173d8a03e8707f1510f"
],
"Parent": "",
"Comment": "",
"Created": "2016-01-26T17:48:34.465253028Z",
"Container": "cc20825e9e02f79fe62f1b08bc30aea4299dbcd77ad0da58b00dec38aba7334a",
"ContainerConfig": {
"Hostname": "d2d404286fc4",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) CMD [\"/bin/bash\"]"
],
"Image": "4913eece27c087d06635d32b98c50464b2f1d17bba86be7d4616738f1cfef0af",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"DockerVersion": "1.8.3",
"Author": "",
"Config": {
"Hostname": "d2d404286fc4",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"/bin/bash"
],
"Image": "4913eece27c087d06635d32b98c50464b2f1d17bba86be7d4616738f1cfef0af",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 131299498,
"VirtualSize": 131299498,
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:3cbe18655eb617bf6a146dbd75a63f33c191bf8c7761bd6a8d68d53549af334b",
"sha256:84cc3d400b0d610447fbdea63436bad60fb8361493a32db380bd5c5a79f92ef4",
"sha256:ed58a6b8d8d6a4e2ecb4da7d1bf17ae8006dac65917c6a050109ef0a5d7199e6",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
]
}
}
]
r
这里docker会返回一个字典
用-f 参数就可以获取其中一个
root@SSS:/data# docker inspect ubuntu:15.04 -f {{".Id"}}
sha256:d1b55fd07600b2e26d667434f414beee12b0771dfd4a2c7b5ed6f2fc9e683b43
用docker history 可以查看镜像历史
root@SSS:/data# docker history ubuntu:15.04
IMAGE CREATED CREATED BY SIZE COMMENT
d1b55fd07600 2 years ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 2 years ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\... 1.88 kB
<missing> 2 years ago /bin/sh -c echo '#!/bin/sh' > /usr/sbin/po... 701 B
<missing> 2 years ago /bin/sh -c #(nop) ADD file:3f4708cf445dc1b... 131 MB
[3] 搜索镜像
使用docker serch 可以搜索镜像名称
支持的参数有:
--automated=ture|false 仅显示 自动创建的镜像,默认为否
--no-trunc=ture|false 输出信息不截断显示 默认为否
-s 指定评分
root@SSS:/data# docker search --automated -s 3 nginx
Flag --automated has been deprecated, use --filter=automated=true instead
Flag --stars has been deprecated, use --filter=stars=3 instead
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 1300 [OK]
richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable ... 540 [OK]
jrcs/letsencrypt-nginx-proxy-companion LetsEncrypt container to use with nginx as... 338 [OK]
webdevops/php-nginx Nginx with PHP-FPM 97 [OK]
zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server ... 48 [OK]
bitnami/nginx Bitnami nginx Docker Image 45 [OK]
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 31 [OK]
tobi312/rpi-nginx NGINX on Raspberry Pi / armhf 19 [OK]
wodby/drupal-nginx Nginx for Drupal container image 9 [OK]
webdevops/nginx Nginx container 8 [OK]
blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 8 [OK]
nginxdemos/hello NGINX webserver that serves a simple page ... 5 [OK]
1science/nginx Nginx Docker images that include Consul Te... 4 [OK]
[4] 删除镜像
docker rmi 指定tag 或者 ID
-f 强制删除正在运行的容器
[5] 创建镜像
第一天docker入门的更多相关文章
- Docker学习第一天(Docker入门&&Docker镜像管理)
简介 今天小区的超市买零食老板给我说再过几天可能就卖完了我有点诧异,老板又说厂家不生产了emmm 今天总算开始docker了! 1.Docker? 1.什么是Docker Docker 是一个开源的应 ...
- Docker入门 第一课 --.Net Core 使用Docker全程记录
微服务架构无疑是当前最火热的开发架构,而Docker作为微服务架构的首选工具,是我们必须要了解掌握的. 我通过一天的时间,网上查文档,了解基础概念,安装Docker,试验Docker命令,通过Dock ...
- Docker 入门 第一部分: 定位和设置
目录 Docker 入门 第一部分: 定位和设置 Docker概念 镜像和容器 容器和虚拟机 准备你的Docker环境 测试 Docker 的版本 测试 Docker 安装 回顾 总结 Docker ...
- 第三章 Docker 入门
第三章 docker 入门 3.1 确保docker已经就绪 首先查看docker程序是否存在,功能是否正常 [#3#cloudsoar@cloudsoar-virtual-machine ~]$su ...
- Docker入门教程(七)Docker API
Docker入门教程(七)Docker API [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第七篇,重点介绍了Docker Registry API和 ...
- Docker入门教程(五)Docker安全
Docker入门教程(五)Docker安全 [编者的话]DockOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第五篇,介绍了Docker的安全问题,依然是老话重谈,入门者可以通 ...
- Docker入门教程(二)命令
Docker入门教程(二)命令 [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第二篇,介绍了Docker的基本命令以及命令的用法和功能. 在Docker ...
- Docker入门教程(一)介绍
http://dockone.io/article/101 Docker入门教程(一)介绍 [编者的话]DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第一篇,介绍了 ...
- Docker 入门实践
欢迎大家前往腾讯云技术社区,获取更多腾讯海量技术实践干货哦~ 作者:张戈 导语 本文从新手视角记录了一个实际的Dokcer应用场景从创建.上传直到部署的详细过程,并简单的介绍了腾讯云容器服务的使用方法 ...
随机推荐
- RHEL/CentOS 6.x使用EPEL6与remi的yum源安装MySQL 5.5.x
PS:如果既想获得 RHEL 的高质量.高性能.高可靠性,又需要方便易用(关键是免费)的软件包更新功能,那么 FedoraProject 推出的 EPEL(Extra Packages for Ent ...
- C++STL之multiset多重集合容器
multiset多重集合容器 multiset与set一样, 也是使用红黑树来组织元素数据的, 唯一不同的是, multiset允许重复的元素键值插入, 而set则不允许. multiset也需要声明 ...
- 2018.7.6 js实现点击事件---点击小图出现大图---时间定时器----注册表单验证
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- linq 查询的两种方法 (在EF model中实现)
众所周知:linq查询有两种方式 1.通过linq表达式查询 2.是通过linq方法查询 代码中 每一步都有注释
- Linux---who命令学习
who命令 获取正在登录系统的用户 使用Linux的who命令 第一个参数book代表用户名,第二个参数tty7代表终端名,第三个参数代表时间,第四个参数代表用户的登录地址. 阅读手册 使用命令读手册 ...
- AngularJS 控制器其他实例
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- python的**和*
1.**两个乘号就是乘方,比如2**4,结果就是2的4次方,结果是16一个乘号*,如果操作数是两个数字,就是这两个数字相乘,如2*4,结果为8*如果是字符串.列表.元组与一个整数N相乘,返回一个其所有 ...
- securecrt颜色设置
https://blog.csdn.net/zq710727244/article/details/53909801
- CocoaAsyncSocket使用
代理的.h文件 #import <Foundation/Foundation.h> #import "GCDAsyncSocket.h" typedef void(^S ...
- mysql指定id默认第一
有个需求 家庭创建人要默认排第一,刚开始用加入家庭的时间排序可以 好简单, 后来加了一个需求 家庭创建人可以转移,结果按时间排序就不行了,又不想去写循环重新排序 就各种百度, 等于就是指定ID排最后 ...