Docker 入门资料收集
收集Docker入门可能用得到的资料,开发机系统为windows,包含10和7
下载安装
- https://download.docker.com/win/
- https://download.docker.com/win/stable/Docker for Windows Installer.exe
- 官方文档
- 中文安装文档
- 如果装有chocolatey,没有的话安装也很快命令行安装,建议用powershell执行
choco install docker-desktop -y
安装Docker - 安装完需要重启完成完整安装
PS C:\WINDOWS\system32> choco install docker-desktop -y
Chocolatey v0.10.11
Installing the following packages:
docker-desktop
By installing you accept licenses for the packages.
Progress: Downloading docker-desktop 2.0.0.0... 100%
docker-desktop v2.0.0.0 [Approved]
docker-desktop package files install completed. Performing other installation steps.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Error - hashes do not match. Actual value was '527558BD0AC89F3916A3AD301AE3C12E97E400F7630261C97427A16A4014B26E'.
Downloading docker-for-windows
from 'https://download.docker.com/win/stable/28905/Docker%20for%20Windows%20Installer.exe'
Progress: 100% - Completed download of H:\Cache\choco\docker-desktop\2.0.0.0\Docker for Windows Installer.exe (537.71 MB).
Download of Docker for Windows Installer.exe (537.71 MB) completed.
Hashes match.
Installing docker-for-windows...
docker-for-windows has been installed.
docker-desktop may be able to be automatically uninstalled.
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The install of docker-desktop was successful.
Software installed to 'C:\Program Files\Docker\Docker'
Chocolatey installed 1/1 packages.
See the log for details (H:\Program Files\Chocolatey\logs\chocolatey.log).
运行
- 运行hello-world,执行
docker run hello-world
- 安装更多可参考http://www.runoob.com/docker/docker-install-mysql.html
PS C:\Users\12504> docker -v
Docker version 18.09.0, build 4d60db4
PS C:\Users\12504> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:b3a26e22bf55e4a5232b391281fc1673f18462b75cdc76aa103e6d3a2bce5e77
Status: Downloaded newer image for 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.
(amd64)
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
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
PS C:\Users\12504>
资源汇总
- 部分复制于以下网站:
名词解释
- http://www.runoob.com/docker/docker-architecture.html
- 一句话概括:在Docker主机(Host,物理机)上通过Docker Machine命令行工具安装Docker 客户端(Client),然后从Docker 仓库(Registry,官方Docker Hub)拉取Docker 镜像(Images,相当于软件包)运行,运行的东西叫做Docker 容器(Container,独立运行的应用)。
Docker官方英文资源
- docker官网:http://www.docker.com
- Docker windows入门:https://docs.docker.com/windows/
- Docker Linux 入门:https://docs.docker.com/linux/
- Docker mac 入门:https://docs.docker.com/mac/
- Docker 用户指引:https://docs.docker.com/engine/userguide/
- Docker 官方博客:http://blog.docker.com/
- Docker Hub: https://hub.docker.com/
- Docker开源: https://www.docker.com/open-source
Docker中文资源
-
docker-cn.com为官方网站翻译
-
Docker中文网站:https://www.docker-cn.com/
-
Docker中文网站:http://www.docker.org.cn
-
Docker入门教程: http://www.docker.org.cn/book/docker.html
-
Docker安装手册:http://www.docker.org.cn/book/install.html
-
一小时Docker教程 :https://blog.csphere.cn/archives/22
-
docker从入门到实践:- http://dockerpool.com/static/books/docker_practice/index.html
-
DockerPPT:http://www.docker.org.cn/dockerppt.html
-
推荐入门教程:http://www.ruanyifeng.com/blog/2018/02/docker-tutorial.html
镜像加速
- Docker 中国官方镜像加速 https://www.docker-cn.com/registry-mirror
- 网易加速器:http://hub-mirror.c.163.com
- 官方中国加速器:https://registry.docker-cn.com
- ustc的镜像:https://docker.mirrors.ustc.edu.cn
- daocloud(注册后使用):https://www.daocloud.io/mirror#accelerator-doc
命令大全
- https://docs.docker.com/engine/reference/run/
- http://www.runoob.com/docker/docker-command-manual.html
- 主要分为:
- 容器生命周期管理
- run
- start/stop/restart
- kill
- rm
- pause/unpause
- create
- exec
- 容器操作
- ps
- inspect
- top
- attach
- events
- logs
- wait
- export
- port
- 容器rootfs命令
- commit
- cp
- diff
- 镜像仓库
- login
- pull
- push
- search
- 本地镜像管理
- images
- rmi
- tag
- build
- history
- save
- import
- info|version
- info
- version
- 容器生命周期管理
- http://www.runoob.com/docker/docker-command-manual.html
界面管理
问题集合
共享文件夹
- 将文件路径映射到物理机,win10可以
c://Users/username
,但win7下不行,原理可能是命令行做了处理转换。 - 下面的讨论提到
/c/Users/username
可行,通过toolbox安装的会有一个快速启动工具快捷方式,那里做了处理,将c盘的Users目录共享到linux虚拟机了。经过验证,登录virtualbox的linux虚拟机,docker使用的是叫做default的虚拟机,里面的根目录就有c,所以/c/Users/username
可行。经过实践,win7上使用的是virtualbox,启动的linux虚拟机自动共享了c盘的用户文件夹,所以我们可以手动添加其他盘共享。 - 另外,不同的命令行终端处理也不一样,可能有时候用
cmd.exe
和powershell
或者git bash
结果都不一样。 - 设置共享文件夹 https://github.com/moby/moby/issues/12590
ssh到docker虚拟机
- win7下使用的是virtualbox,镜像使用boot2docker,45M大小,所以相关说明应该查看官网文档
- https://github.com/boot2docker/boot2docker#ssh-into-vm
局域网共享
- win7,使用桥接网络,再新建虚拟机, 镜像使用boot2docker,这样docker所在网段与主机一样,但是这样就无法使用
docker toolbox
那些工具了,但是可以通过ssh连接,用户名密码:
user: docker
pass: tcuser
- 切换到root
sudo su root
常用命令
- 监控资源
docker stats
总结
- 经过动手实践,才会更深一层理解Docker,知道它能干什么,可以解决什么问题,如果没有配置环境的烦恼,请速速离开,因为学习成本将会让人从未入门到放弃。
点击查看更多内容
1人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦