为了账号安全,请及时绑定邮箱和手机立即绑定

Docker 入门资料收集

2018.12.28 08:24 1096浏览

Docker 入门资料收集

收集Docker入门可能用得到的资料,开发机系统为windows,包含10和7

下载安装

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中文资源

镜像加速

命令大全

界面管理

问题集合

共享文件夹

  • 将文件路径映射到物理机,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.exepowershell者git bash结果都不一样。
  • 设置共享文件夹 https://github.com/moby/moby/issues/12590

ssh到docker虚拟机

局域网共享

  • win7,使用桥接网络,再新建虚拟机, 镜像使用boot2docker,这样docker所在网段与主机一样,但是这样就无法使用docker toolbox那些工具了,但是可以通过ssh连接,用户名密码:
user: docker
pass: tcuser
  • 切换到rootsudo su root

常用命令

  • 监控资源docker stats

总结

  • 经过动手实践,才会更深一层理解Docker,知道它能干什么,可以解决什么问题,如果没有配置环境的烦恼,请速速离开,因为学习成本将会让人从未入门到放弃。
点击查看更多内容

本文首次发布于慕课网 ,转载请注明出处,谢谢合作

1人点赞

若觉得本文不错,就分享一下吧!

评论

相关文章推荐

正在加载中
意见反馈 邀请有奖 帮助中心 APP下载
官方微信

举报

0/150
提交
取消