Docker学习3 - Hello World
来源:互联网 发布:ubuntu与fedora的异同 编辑:程序博客网 时间:2024/04/30 00:52
Hello-World
所有环境准备就绪,试着运行一下hello world吧(做为程序员, 你懂的)
参考
http://docs.docker.com/mac/step_two/
[root@centos7-docker ~]# docker run hello-world
Unable to find image 'hello-world:latest' locallyTrying to pull repository docker.io/hello-world ...
91c95931e552: Download complete
a8219747be10: Download complete
Status: Downloaded newer image for docker.io/hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
For more examples and ideas, visit:
http://docs.docker.com/userguide/
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
从提示信息我们可以看出
1. 检查hello-world image
2. 发现没有,从Docker Hub 中下载
3. 加载并运行run
Whalesay
按照quickstart中的示例,我们进入
hub.docker.com
输入whalesay(鲸鱼说,和docker logo匹配 ^_^),能看到
在information中我们能看到这个是用来展示docker的一个sample,并且展示了用法
执行命令
由于国内万恶的墙,所以比较慢,多试几次,或者自己去买个VPN
这次执行完了之后,相当于whalesay已经存储在本机了,再次执行就快多了
我们可以查看和管理我们的image
[root@centos7-docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/docker/whalesay latest fb434121fc77 8 weeks ago 247 MB
docker.io/hello-world latest 91c95931e552 3 months ago 910 B
可以看到我们有2个image
Build you own image
http://docs.docker.com/mac/step_four/
如果我们想对之前的whalesay进行一些改动怎么呢?
[root@centos7-docker ~]# mkdir -p mydockerbuild
[root@centos7-docker ~]# cd mydockerbuild/
[root@centos7-docker mydockerbuild]# vim Dockerfile
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get -y install fortunes
CMD /usr/games/fortune -a | cowsay
这段逻辑文档中有解释, 没太仔细去看,也不需要仔细去看
其实就是一些执行脚本,像shell脚本一样
这里是安装fortunes, 然后fortune -a命令的输出结果做为cowsay命令的输入
执行命令如下
[root@centos7-docker mydockerbuild]# docker build -t docker-whale .
Sending build context to Docker daemon 158.8 MB
...snip...
Removing intermediate container a8e6faa88df3
Successfully built 7d9495d03763
-t 代表启动instance名字是docker-whale, 在启动这个instance的时候会自动调用Dockerfile脚本
这个时候我们再去查看我们有几个images了
[root@centos7-docker mydockerbuild]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker-whale latest beda7d481894 44 minutes ago 255.5 MB
docker.io/docker/whalesay latest fb434121fc77 8 weeks ago 247 MB
docker.io/hello-world latest 91c95931e552 3 months ago 910 B
我们看见新增了docker-whale了
运行
Help
每个命令我们不可能记得这么多,所以,寻找帮助很重要
[root@centos7-docker mydockerbuild]#
[root@centos7-docker ~]#[root@centos7-docker ~]# docker run --help
[root@centos7-docker ~]# docker help run
也可以找男人^_^
[root@centos7-docker ~]# man docker
[root@centos7-docker ~]# man docker run
- Docker学习3 - Hello World
- docker学习笔记(二):Hello World
- Docker之Hello World
- docker之hello world
- docker run hello-world
- Docker Hello World
- Docker Hello World
- Docker Hello World
- Docker化应用:Hello World
- docker(二):Mac docker hello-world
- Docker入门学习(2)----Docker安装和第一个hello-world
- SSH学习3:maven Struts Hello World
- greenDao_2.0.0学习笔记3-Hello World
- Shader学习 Hello World!
- maven学习 ----hello-world
- v8学习---Hello world
- 学习scala-hello-world!
- Android学习--Hello World
- 从is(":checked")说起
- lamp源码安装
- 四元数
- uva 11178
- ubuntu安装和卸载MAC主题
- Docker学习3 - Hello World
- 深入浅出RxJava(一:基础篇)
- 窗口分割
- Ensemble method of machine learning 机器学习中的组合方法
- HDU 2054 A == B ? 字符串比对
- Num 13: OJ网站上常见错误提示 [ 新手 ]
- 插排O[n]无缝实现:顺序读写迭代器访问+两步迭代间独立性
- windows下文件夹操作SHFILEOPSTRUCT
- listView分批和分页加载数据