[Docker]初次接触
Docker 初次接触
近期看了不少docker介绍性文章,也听了不少公开课,于是今天去官网逛了逛,发现了一个交互式的小教程于是决定跟着学习下。
仅仅是把认为重点的知识记录下来,不是非常系统的学习和笔记。
理论部分
- Docker 引擎包括了两个部分,一个守护进程作为server端来管理全部的容器。
一个client。能够远程来控制服务端。
- Docker有公共的云端仓库 Docker Hub Registry。里面有能够使用的镜像
- 你能够觉得容器containers就是沙箱box中的一个进程。这个盒子中包括了全部一个进程须要的东西,文件系统。系统库。shell等等,仅仅是默认情况下他们是没有执行的。
- 我们能够在操纵和改变容器,然后通过命令保存成新的镜像
- 在须要使用容器id的地方。我们能够仅仅输入前几个字符
操作部分
docker help 能够查看能使用的命令和简单描写叙述
查看版本号
you@tutorial:~$ docker version
Docker Emulator version 0.1.3
Emulating:
Client version: 0.5.3
Server version: 0.5.3
Go version: go1.1
从公共云仓库中查找一个镜像
tutorial
you@tutorial:~$ docker search tutorial
Found 1 results matching your query (“tutorial”)
NAME DESCRIPTION
learn/tutorial An image for the interactive tutorial
从仓库中拉取一个镜像。注意要写这个镜像的全名
you@tutorial:~$ docker pull learn/tutorial
Pulling repository learn/tutorial from https://index.docker.io/v1
Pulling image 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c (precise) from ubuntu
Pulling image b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc (12.10) from ubuntu
Pulling image 27cf784147099545 () from tutorial
启动一个docker而且执行命令
you@tutorial:~$ docker run learn/tutorial echo “hello boy”
hello boy
tips:这里是启动了一个容器而且执行了一个命令,当命令执行完的时候容器就停止了。能够通过docker的ps命令查看当前正在执行的容器。
you@tutorial:~$ docker ps
ID IMAGE COMMAND CREATED STATUS PORTS
安装一个软件ping
you@tutorial:~$ docker run learn/tutorial apt-get install -y ping
Reading package lists…
Building dependency tree…
The following NEW packages will be installed:
iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 56.1 kB in 1s (50.3 kB/s)
Selecting previously unselected package iputils-ping.
(Reading database … 7545 files and directories currently installed.)
Unpacking iputils-ping (from …/iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) …
Setting up iputils-ping (3:20101006-1ubuntu1)
查看改变之后的容器,然后保存成learn/ping
you@tutorial:~$ docker ps -l
ID IMAGE COMMAND CREATED STATUS PORTS
6982a9948422 ubuntu:12.04 apt-get install ping 1 minute ago Exit 0
you@tutorial:~$ docker commit 6982 learn/ping
effb66b31edb
使用新的镜像ping
google
you@tutorial:~$ docker run learn/ping ping www.google.com
PING www.google.com (74.125.239.129) 56(84) bytes of data.
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=1 ttl=55 time=2.23 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=2 ttl=55 time=2.30 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=3 ttl=55 time=2.27 ms
64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=4 ttl=55 time=2.30 ms
查看正在执行的容器的状态
you@tutorial:~$ docker ps
ID IMAGE COMMAND CREATED STATUS PORTS
efefdc74a1d5 learn/ping:latest ping www.google.com 37 seconds ago Up 36 seconds
you@tutorial:~$ docker inspect efef
[2013/07/30 01:52:26 GET /v1.3/containers/efef/json
{
“ID”: “efefdc74a1d5900d7d7a74740e5261c09f5f42b6dae58ded6a1fde1cde7f4ac5”,
“Created”: “2013-07-30T00:54:12.417119736Z”,
“Path”: “ping”,
“Args”: [
“www.google.com”
],
“Config”: {
“Hostname”: “efefdc74a1d5”,
“User”: “”,
“Memory”: 0,
“MemorySwap”: 0,
“CpuShares”: 0,
“AttachStdin”: false,
“AttachStdout”: true,
“AttachStderr”: true,
“PortSpecs”: null,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: null,
“Cmd”: [
“ping”,
“www.google.com”
],
“Dns”: null,
“Image”: “learn/ping”,
“Volumes”: null,
“VolumesFrom”: “”,
“Entrypoint”: null
},
“State”: {
“Running”: true,
“Pid”: 22249,
“ExitCode”: 0,
“StartedAt”: “2013-07-30T00:54:12.424817715Z”,
“Ghost”: false
},
“Image”: “a1dbb48ce764c6651f5af98b46ed052a5f751233d731b645a6c57f91a4cb7158”,
“NetworkSettings”: {
“IPAddress”: “172.16.42.6”,
“IPPrefixLen”: 24,
“Gateway”: “172.16.42.1”,
“Bridge”: “docker0”,
“PortMapping”: {
“Tcp”: {},
“Udp”: {}
}
},
“SysInitPath”: “/usr/bin/docker”,
“ResolvConfPath”: “/etc/resolv.conf”,
“Volumes”: {},
“VolumesRW”: {}
查看本地镜像
you@tutorial:~$ docker images
ubuntu latest 8dbd9e392a96 4 months ago 131.5 MB (virtual 131.5 MB)
learn/tutorial latest 8dbd9e392a96 2 months ago 131.5 MB (virtual 131.5 MB)
learn/ping latest effb66b31edb 10 minutes ago 11.57 MB (virtual 143.1 MB)
把镜像推送到云端
docker inspect efe
tips: 这个是推送到docker的云仓库的,会有你自己的独立命名控件。账号注冊地址
这个十分钟交互式的短教程能够让我们对docker有个感性的认识。最主要的使用和激发兴趣。
本文出自 “orangleliu笔记本”博客,请务必保留此出处http://blog.csdn.net/orangleliu/article/details/38648075
[Docker]初次接触的更多相关文章
- 初次接触json...
这两天发现很多网站显示图片版块都用了瀑布流模式布局的:随着页面滚动条向下滚动,这种布局还会不断加载数据并附加至当前尾部.身为一个菜鸟级的程序员,而且以后可能会经常与网站打交道,我觉得我还是很有必要去尝 ...
- 初次接触GWT,知识点总括
初次接触GWT,知识点概括 前言 本人最近开始研究 GWT(Google Web Toolkit) ,现将个人的一点心得贴出来,希望对刚开始接触 GWT的程序员们有所帮助,也欢迎讨论,共同进步. 先说 ...
- 初次接触:DirectDraw
第六章 初次接触:DirectDraw 本章,你将初次接触DirectX中最重要的组件:DirectDraw.DirectDraw可能是DirectX中最强大的技术,因为其贯穿着2D图形绘制同时其帧缓 ...
- 初次接触scrapy框架
初次接触这个框架,先订个小目标,抓取QQ首页,然后存入记事本. 安装框架(http://scrapy-chs.readthedocs.io/zh_CN/0.24/intro/install.html) ...
- javaweb中的乱码问题(初次接触时写)
javaweb中的乱码问题 在初次接触javaweb中就遇到了乱码问题,下面是我遇到这些问题的解决办法 1. 页面乱码(jsp) 1. 在页面最前方加上 <%@ page language=&q ...
- 初次接触Java
今天初次接触Eclipse,学着用他来建立java工程,话不多说,来看看今天的成果! 熟悉自己手中的开发工具,热热身 刚上手别慌,有问题找度娘 刚刚拿到这个软件的安装包我是一脸懵逼的,因为是从官网下载 ...
- -1.记libgdx初次接触
学习一门技术最难的是开发环境变量配置和工具配置,以下为我初次接触libgdx时遇到的问题 几个难点记录下 gradle 直接用下到本地,然后放到d盘,链接到就行(gradle-wrapper.prop ...
- tensorflow初次接触记录,我用python写的tensorflow第一个模型
tensorflow初次接触记录,我用python写的tensorflow第一个模型 刚用python写的tensorflow机器学习代码,训练60000张手写文字图片,多层神经网络学习拟合17000 ...
- 初次接触ARM开发,理清这四个开发思路很重要!
初次接触ARM开发,理清这四个开发思路很重要! 由于涉及编程,学习ARM单片机系统对于从事电子电路的设计者来说是有些困难的,学习知识不难,难的是理清其中的开发思路,找到一个好的起点.本文就将从这一步入 ...
随机推荐
- 什么是Web前端,Web前端是做什么的?
什么是Web前端 Web前端,顾名思义是来做Web的前端的.而Web前端开发应该就是来开发基于Web前端的相关应用的或者说是来开发前端的.那么,前端又是什么呢?我们这里所说的前端泛指Web前端,也就是 ...
- Thinkphp的时间判断
在做项目的过程中,非常频繁地遇到时间这个问题,像时间的比较,特定时间执行某一操作,但是现在只解决了一部分问题,先说明一下时间的判断问题. 很简单,时间,不断使date(),now(),都是字符串类型的 ...
- CSS自学笔记(1):CSS简介
一.什么是CSS CSS(Cascading Style Sheet(级联样式表))是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言. ...
- 关于C语言中结构体中的结构体成员导致的字节对齐问题
关于结构体的字节对齐是什么,就不赘述,再此附上一篇文章,介绍字节对齐:http://www.linuxsong.org/2010/09/c-byte-alignment/ 这里的结构体字节对齐的数据类 ...
- C++中的引用到底是什么
这也算是一个老生常谈的问题,写这个其实就是想趁着暑假把博客丰富一下. 咱随便在谷哥.度娘.病软引擎上搜搜都可以得到各种关于引用的解释,无非就是"引用不同于指针,引用是一个变量的别名" ...
- Junit技巧
测试套件: @RunWith(Suite.class) @Suite.SuiteClasses({TaskTest1.class, TaskTest2.class, TaskTest3.class}) ...
- SQL Server用户自定义类型与统计信息
用户自定义数据类型不支持统计信息! 所以查询对它的查询会慢一些.
- jQuery-zclip实现复制内容到剪切板
jQuery-zclip是一个复制内容到剪贴板的jQuery插件,使用它我们不用考虑不同浏览器和浏览器版本之间的兼容问题.jQuery-zclip插件需要Flash的支持,使用时记得安装Adobe F ...
- [Leetcode][Python]23: Merge k Sorted Lists
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 23: Merge k Sorted Listshttps://oj.leet ...
- Qt编写端口扫描工具
Qt提供了QTcpSocket类,可以方便地建立TCP连接.利用这一功能,Maxiee编写了一个简单地端口扫描工具. 软件的功能就是,扫描某一网段的固定端口,如80端口,若目的地址开放了这一端口,那么 ...