开始docker
$ curl -fsSL https://get.docker.com/ | sh
.docker run hello-world
$ docker run hello-world
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$ sudo usermod -aG docker $(whoami)
$ sudo reboot
注意:需要reboot之后才能使用
zane@zane-V:~$ sudo docker run hello-world Hello from Docker!
This message shows that your installation appears to be working correctly.
- Docker客户端联系Docker用例
- Docker用例从Docker Hub 中将“hello-world”image 拉下来。
- Docker 用例从“hello-world” image 创建一个新的容器。而这个image运行着产生你现在读到的信息的 可执行性文件。
- Docker用例再讲这些输出传送到Docker客户端,然后Docker客户端在将这些信息传送到你的屏幕
zane@zane-V:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
767a0a0f0bae hello-world "/hello" minutes ago Exited () minutes ago silly_mcnulty
9e6a3cb1e18b hello-world "/hello" minutes ago Exited () minutes ago tender_kare zane@zane-V:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- docker ps 仅显示当前正在运行的容器
- hello-world已经退出因此不会显示
.png)
- docker
- 告诉操作系统正在使用docker程序
- hello-world
- 告诉docker将hello-world这个image加载到容器
- run
- 一个创建运行docker容器的子命令
- 是一个文件系统和参数集合,用在运行时。
- 没有状态也不可以改变
- 一个正运行的image实例
- 检查你是否有hello-world 这个镜像
- 从Docker Hub下载这个image
- 加载这个image到container然后运行
zane@zane-V:~$ docker run docker/whalesay cowsay boo
Unable to find image 'docker/whalesay:latest' locally
latest: Pulling from docker/whalesay e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
00bf65475aba: Pull complete
c57b6bcc83e3: Pull complete
8978f6879e2f: Pull complete
8eed3712d2cf: Pull complete
Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Status: Downloaded newer image for docker/whalesay:latest
_____
< boo >
-----
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
zane@zane-V:~/mydockerbuild$ docker build -t docker-whale .
---> 6b362a9f73eb
zane@zane-V:~/mydockerbuild$ docker build -t docker-whale .
Sending build context to Docker daemon 14.85 kB
Step : FROM docker/whalesay:latest
---> 6b362a9f73eb
Step : RUN apt-get -y update && apt-get install -y fortunes
---> Running in e9dbb3ff0ba2
Ign http://archive.ubuntu.com trusty InRelease
Get: http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
.......
.......
.......
Setting up fortunes-min (:1.99.-) ...
Setting up fortunes (:1.99.-) ...
Processing triggers for libc-bin (2.19-0ubuntu6.) ...
---> 4c9a56721bad
Removing intermediate container e9dbb3ff0ba2
Step : CMD /usr/games/fortune -a | cowsay
---> Running in b1aa7efec08e
---> d09756981eeb
Removing intermediate container b1aa7efec08e
Successfully built d09756981eeb
现在已经创建了一个叫做docker-whale的image。
zane@zane-V:~/mydockerbuild$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest d09756981eeb minutes ago 275.1 MB
hello-world latest c54a2cc56cbb months ago 1.848 kB
docker/whalesay latest 6b362a9f73eb months ago MB
zane@zane-V:~/mydockerbuild$ docker run docker-whale
____________________________________
/ This is National Non-Dairy Creamer \
\ Week. /
------------------------------------
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/ zane@zane-V:~/mydockerbuild$ docker run docker-whale
_______________________________________
/ People who take cold baths never have \
\ rheumatism, but they have cold baths. /
---------------------------------------
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
zane@zane-V:~/mydockerbuild$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest d09756981eeb minutes ago 275.1 MB
hello-world latest c54a2cc56cbb months ago 1.848 kB
docker/whalesay latest 6b362a9f73eb months ago MB
.png)
zane@zane-V:~/mydockerbuild$ docker tag d09756981eeb zane0306/docker-whale:latest
zane@zane-V:~/mydockerbuild$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest d09756981eeb minutes ago 275.1 MB
zane0306/docker-whale latest d09756981eeb minutes ago 275.1 MB
hello-world latest c54a2cc56cbb months ago 1.848 kB
docker/whalesay latest 6b362a9f73eb months ago MB
zane@zane-V:~/mydockerbuild$ 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: zane0306
Password:
Login Succeeded e.docker push 命令推送自己image到存储库
zane@zane-V:~/mydockerbuild$ docker push zane0306/docker-whale
The push refers to a repository [docker.io/zane0306/docker-whale]
9748ff4991ff: Pushed
5f70bf18a086: Mounted from docker/whalesay
d061ee1340ec: Mounted from docker/whalesay
d511ed9e12e1: Mounted from docker/whalesay
091abc5148e4: Mounted from docker/whalesay
b26122d57afa: Mounted from docker/whalesay
37ee47034d9b: Mounted from docker/whalesay
528c8710fd95: Mounted from docker/whalesay
1154ba695078: Mounted from docker/whalesay
latest: digest: sha256:62b528c43afd3a2771a167a21ce005a5ee49514109d2af870336f6880ec4eca7 size:
zane@zane-V:~/mydockerbuild$ docker images;
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest d09756981eeb minutes ago 275.1 MB
zane0306/docker-whale latest d09756981eeb minutes ago 275.1 MB
hello-world latest c54a2cc56cbb months ago 1.848 kB
docker/whalesay latest 6b362a9f73eb months ago MB zane@zane-V:~/mydockerbuild$ docker rmi -f d09756981eeb
Untagged: docker-whale:latest
Untagged: zane0306/docker-whale:latest
Untagged: zane0306/docker-whale@sha256:62b528c43afd3a2771a167a21ce005a5ee49514109d2af870336f6880ec4eca7
Deleted: sha256:d09756981eebc2a3fa7d200e57be74e89147465969aa92dcbd34b3f541a90219
Deleted: sha256:4c9a56721bad2895ec49a1683737d132f13f2ca99627c5ae3b4368f1b2583919 zane@zane-V:~/mydockerbuild$ docker images;
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest c54a2cc56cbb months ago 1.848 kB
docker/whalesay latest 6b362a9f73eb months ago MB
zane@zane-V:~/mydockerbuild$ docker run zane0306/docker-whale
Unable to find image 'zane0306/docker-whale:latest' locally
latest: Pulling from zane0306/docker-whale e190868d63f8: Already exists
909cd34c6fd7: Already exists
0b9bfabab7c1: Already exists
a3ed95caeb02: Already exists
00bf65475aba: Already exists
c57b6bcc83e3: Already exists
8978f6879e2f: Already exists
8eed3712d2cf: Already exists
c7b22951dde1: Already exists
Digest: sha256:62b528c43afd3a2771a167a21ce005a5ee49514109d2af870336f6880ec4eca7
Status: Downloaded newer image for zane0306/docker-whale:latest
_________________________________________
/ As usual, this being a 1.3.x release, I \
| haven't even compiled this kernel yet. |
| So if it works, you should be doubly |
| impressed. (Linus Torvalds, announcing |
| kernel 1.3. on the linux-kernel |
\ mailing list.) /
-----------------------------------------
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
- Docker Hub 与本地image的push,pull
- 在Docker Hub上寻找自己感兴趣的image
- image 和 contaniers
- image
- image 是一个文件系统+参数集合。
- 没有状态也不可以改变
- contaniers
- 一个正在运行的image实例
- image
- 利用Dockerfile 创建自己的image
- 编写Dockerfile
- a.指定基础image
- FROM docker/whalesay:latest
- b.安装fortunes程序到image中
- RUN apt-get -y update && apt-get install -y fortunes
- c.增加CMD行
- CMD /usr/games/fortune -a | cowsay
- a.指定基础image
- build image
- zane@zane-V:~/mydockerbuild$ docker build -t docker-whale .
- -t 参数给image一个标签,在之后更容易的运行它。
- 编写Dockerfile
开始docker的更多相关文章
- docker——容器安装tomcat
写在前面: 继续docker的学习,学习了docker的基本常用命令之后,我在docker上安装jdk,tomcat两个基本的java web工具,这里对操作流程记录一下. 软件准备: 1.jdk-7 ...
- Docker笔记一:基于Docker容器构建并运行 nginx + php + mysql ( mariadb ) 服务环境
首先为什么要自己编写Dockerfile来构建 nginx.php.mariadb这三个镜像呢?一是希望更深入了解Dockerfile的使用,也就能初步了解docker镜像是如何被构建的:二是希望将来 ...
- Docker 第一篇--初识docker
已经多年不写博客, 看完<晓松奇谈>最后一期猛然觉醒, 决定仔细梳理下自己这几年的知识脉络. 既然决定写, 那么首先就从最近2年热门的开源项目Docker开始.Docker 这两年在国内很 ...
- 在docker中运行ASP.NET Core Web API应用程序(附AWS Windows Server 2016 widt Container实战案例)
环境准备 1.亚马逊EC2 Windows Server 2016 with Container 2.Visual Studio 2015 Enterprise(Profresianal要装Updat ...
- docker for mac 学习记录
docker基本命令 docker run -d -p 80:80 --name webserver nginx 运行容器并起别名 docker ps 展示目前启动的容器 docker ps -a 展 ...
- scrapy爬虫docker部署
spider_docker 接我上篇博客,为爬虫引用创建container,包括的模块:scrapy, mongo, celery, rabbitmq,连接https://github.com/Liu ...
- [原][Docker]特性与原理解析
Docker特性与原理解析 文章假设你已经熟悉了Docker的基本命令和基本知识 首先看看Docker提供了哪些特性: 交互式Shell:Docker可以分配一个虚拟终端并关联到任何容器的标准输入上, ...
- 开发者的利器:Docker 理解与使用
困扰写代码的机器难免会被我们安装上各种各样的开发工具.语言运行环境和引用库等一大堆的东西,长久以来不仅机器乱七八糟,而且有些相同的软件还有可能会安装不同的版本,这样又会导致一个项目正常运行了,却不小心 ...
- 使用python自动生成docker nginx反向代理配置
由于在测试环境上用docker部署了多个应用,而且他们的端口有的相同,有的又不相同,数量也比较多,在使用jenkins发版本的时候,不好配置,于是想要写一个脚本,能在docker 容器创建.停止的时候 ...
- 微服务与Docker介绍
什么是微服务 微服务应用的一个最大的优点是,它们往往比传统的应用程序更有效地利用计算资源.这是因为它们通过扩展组件来处理功能瓶颈问题.这样一来,开发人员只需要为额外的组件部署计算资源,而不需要部署一个 ...
随机推荐
- loj2061 「HAOI2016」放棋子
答案就是错排数 n = int(input()) f = [0] * 205 f[0] = 1 for i in range(2, n+1): f[i] = (i-1) * (f[i-1] + f[i ...
- C 语言 习题 1-10
练习 1-10 编写一个将输入复制到输出的程序,并将其中的制表符替换为\t,把回退符替换为\b,把反斜杠替按为\\.这样可以将制表符和回退符以可见的方式显示出来. #include<stdio. ...
- 14 Java虚拟机实现 synchronized
java 中的 synchronized 运行 在 Java 中,我们经常用 synchronized 关键字对程序进行加锁.无论是一个代码块还是静态方法或者实例方法,都可以直接用 synchroni ...
- 【转】 [Unity3D]手机3D游戏开发:场景切换与数据存储(PlayerPrefs 类的介绍与使用)
http://blog.csdn.net/pleasecallmewhy/article/details/8543181 在Unity中的数据存储和iOS中字典的存储基本相同,是通过关键字实现数据存储 ...
- springboot添加事务
(转自:http://www.cnblogs.com/xingzc/p/6029483.html) 什么是事务? 我们在开发企业应用时,对于业务人员的一个操作实际是对数据读写的多步操作的结合.由于数据 ...
- 【bzoj5018】[Snoi2017]英雄联盟 背包dp
题目描述 正在上大学的小皮球热爱英雄联盟这款游戏,而且打的很菜,被网友们戏称为「小学生」.现在,小皮球终于受不了网友们的嘲讽,决定变强了,他变强的方法就是:买皮肤!小皮球只会玩N个英雄,因此,他也只准 ...
- PIC单片机之时钟设置
PIC单片机之时钟设置 http://blog.csdn.net/superanters/article/details/8541650 内部时钟和外部时钟? PIC单片机有许多型号可以设置成 用外部 ...
- CSA Round 84 Mahattan Center
题目 题目大意 给定平面上的 $n$ 个点和常数 $k$,求 $x$ 轴上的点 $p$ 到 $n$ 个点中距其最近的 $k$ 个点的距离之和的最小值.两点之间的距离定义为曼哈顿距离. 数据范围 $1\ ...
- BZOJ-1043 [HAOI2008]下落的圆盘
几何题... 先把所有圆储存起来,然后对于每个圆我们求得之后放下的圆挡住了的部分,求个并集,并把没被挡到的周长加进答案. #include <cstdlib> #include <c ...
- webpack 样式模块打包深入学习
1. style-loader css-loader sass-loader 分别的作用 style-loader: 将所有的样式嵌入到dom的style属性当中. css-loader: 将css当 ...