win10入门Docke的最简单使用教程

一 win安装docker

这里就不需要过多赘述
docker官方网站下载
不需要什么复杂的下载过程点击 “Download for windows” 就可以进行下载(就在中间别告诉我看不见)

然后点击安装包安装就可以了,等着进度条走完就可以了。无需自行配置安装。
第一步就大功告成了





二 运行

这时大部分都会出现在这里插入图片描述

首先点开那个蓝色的链接,更新一下
上面的蓝色连接
安照里面的前5步就可以了,没必要走完。


然后打开控制面板
控制面板\所有控制面板项\程序和功能 里面左边找到
启用或关闭windows功能 把这两个打开:

在这里插入图片描述
然后再打开docker就没有问题了





三 使用

打开命令字符(cmd)
运行如下命令

docker run hello-world

出现如下就是正常(可能会有点不同,大体差不多)

Microsoft Windows [版本 10.0.18363.1379]
(c) 2019 Microsoft Corporation。保留所有权利。

C:\Users\普天同庆>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete                                                                                             Digest: sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d
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/

注意:因为是国外源,记得使用镜像加速,阿里,网易,腾讯,都可以,因为只是入门,详情就自行百度





四 以centos7为例安装镜像

输入以下命令

#下载官方centos7镜像
docker pull centos:centos7

注意centos:centos7 与centos:7不同,都是都是可以安装。具体有什么区别,请大佬解释一下。
下载完后记得查看一下哦。

#查看当前镜像文件
docker images

这回就是真正的创建容器了,也就是安装centos7系统。

语法:docker run [OPTIONS] IMAGE [COMMAND][ARG]

OPTIONS说明(常用) :有些是一个减号,有些是两个减号
–name=“容器新名字”:为容器指定一个名称;
-d:后台运行容器,并返回容器ID, 也即启动守护式容器;
-i:以交互模式运行容器,通常与-t同时使用;
-t:为容器重新分配一个伪输入终端,通常与-i同时使用;
-P:随机端口映射;
-p:指定端口映射,有以下四种格式
ip:hostPort:containerPort
ip::containerPort
hostPort:containerPort
containerPort

方法一

docker run -it centos:centos7 /bin/bash

方法二

docker run --name centos7 -dit centos:centos7 /bin/bash
##这里会返回一个很长的id号,记得复制下来
docker exec -it  容器ID  bash
##将id替换掉上面的容器id就可以进入centos7了

如:
在这里插入图片描述

4-1进入已创建好的容器

首先先查看容器是否运行

docker ps -a

”STATUS“ 这一行的下面会有显示:
Up 表示运行
Exited 表示未运行

未运行的容器需要输入启动命令

docker start 容器ID

运行后可以输入

docker exec -it 容器ID /bin/bash

停止容器运行

docker stop 容器ID

通过rm命令删除容器

docker rm 容器ID -f

欢迎入门!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值