Tool-Docker-First exploration
2020/11/30 00:19:00
之前工作中接触过Docker,最近在笔记本上想装个Vm虚拟机用,就想着来试试Docker吧。
1.Docker Hub Tutorial
Get started by downloading Docker Desktop, and learn how you can build, tag and share a sample image on Hub.
-
Download:
Docker Desktop installer.exe
-
Clone:
git clone https://github.com/docker/doodle.git
-
Build:
cd doodlecheers2019 ; docker build -t cain95/cheers2019 .
注:实测用了3000+s。
-
Run:
docker run -it --rm cain95/cheers2019
-
Ship:
docker login ; docker push cain95/cheers2019
2.Docker 101 Tutorial
-
Docker Desktop
Docker Desktop is a native application that delivers all of the Docker tools to your Mac or Windows Computer. 1.Open Docker Desktop. (Download here if you don't have it). 2.Type the following command in your terminal: docker run -dp 80:80 docker/getting-started 3.Open your browser to http://localhost 4.Have fun!
-
Play with Docker
Play with Docker is an interactive playground that allows you to run Docker commands on a linux terminal, no downloads required. 1.Log into https://labs.play-with-docker.com/ to access your PWD terminal 2.Type the following command in your PWD terminal: docker run -dp 80:80 docker/getting-started:pwd 3.Wait for it to start the container and click the port 80 badge 4.Have fun!
3. Windows Containers with Docker
First, make sure the Docker installation is working:
docker version
我的server是linux/amd64,不支持windows,尴尬。
解决方法:任务栏右键whale,可以选择切换server为windows。[默认安装时是linux]
Next, pull a base image that’s compatible with the evaluation build, re-tag it and do a test-run:
docker pull microsoft/windowsservercore:10.0.14393.321
//提示error:xxx i/o timeout。
//替换方案,去hub上找了个镜像:
//[windows-servercore](https://hub.docker.com/_/microsoft-windows-servercore)
//docker pull mcr.microsoft.com/windows/servercore:ltsc2019
//docker run mcr.microsoft.com/windows/servercore:ltsc2019
//拉取超时~,参考[配置Docker镜像加速](https://www.runoob.com/docker/docker-mirror-acceleration.html)
//配置Docker镜像加速:
//-网易:https://hub-mirror.c.163.com/
//-阿里云:https://<你的ID>.mirror.aliyuncs.com
///阿里云镜像获取地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
//-七牛云加速器:https://reg-mirror.qiniu.com
//-Docker 官方加速器 https://registry.docker-cn.com (可能不能用了)
//回到原有指令,3.738GB
//2020/12/02 最后还是没下下来,真的放弃了,这是要让人用AWS来实现啊
docker tag microsoft/windowsservercore:10.0.14393.321 microsoft/windowsservercore
docker run microsoft/windowsservercore hostname
Building and pushing Windows container images
Pushing images to Docker Cloud requires a free Docker ID. Storing images on Docker Cloud is a great way to save build artifacts for later user, to share base images with co-workers or to create build-pipelines that move apps from development to production with Docker.
Docker images are typically built with docker build from a Dockerfile recipe, but for this example, we’re going to just create an image on the fly in PowerShell.
"FROM microsoft/windowsservercore `n CMD echo Hello World!" | docker build -t <docker-id>/windows-test-image -
Test the image:
docker run <docker-id>/windows-test-image
Hello World!
Login with docker login
and then push the image:
docker push <docker-id>/windows-test-image
Images stored on Docker Cloud are available in the web interface and public images can be pulled by other Docker users in the Docker Store.
4.Docker 命令大全
容器生命周期管理
容器操作
容器rootfs命令
镜像仓库
本地镜像管理
info|version
5.Docker 资源
-
Docker 官方主页: https://www.docker.com
-
Docker 官方博客: https://blog.docker.com/
-
Docker 官方文档: https://docs.docker.com/
-
Docker Store: https://store.docker.com
-
Docker Cloud: https://cloud.docker.com
-
Docker Hub: https://hub.docker.com
-
Docker 的源代码仓库: https://github.com/moby/moby
-
Docker 发布版本历史: https://docs.docker.com/release-notes/
-
Docker 常见问题: https://docs.docker.com/engine/faq/
-
Docker 远端应用 API: https://docs.docker.com/develop/sdk/
-
Docker 国内镜像
阿里云的加速器:https://help.aliyun.com/document_detail/60750.html
网易加速器: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(注册后使用)