Docker介绍(安装和测试使用)

参考链接1
参考链接2

1 docker安装

#获取最新版本的docker
wget -qO- https://get.docker.com/ | sh
#或者
apt-get install docker.io
#检查是否安装成功以及版本
docker
docker -V

2 术语介绍

docker三大核心:Repositories(仓库)、Images(镜像)和Container(容器);三者可以互相转换。

  • Docker, 平台工具、守护进程
  • Image, 镜像,包括应用及系统的数据包
  • Container, 容器,虚拟机的运行机制
  • Registry, 仓库登记,管理镜像文件
  • Docker hub, Docker官方公有仓库

三大核心的关系,如下图所示:

这里写图片描述

3创建镜像

Docker镜像的创建方式有两种,分别是:

  • 基于现有的镜像修改
  • 直接创建新镜像
    本文介绍基于已有镜像修改的方式,一共分为五步。

3.1 第一步,下载官网的基础镜像

从官网上pull镜像hello-world,并运行

root@apple:/home/kevin/docker# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b04784fba78d: Pull complete 
Digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
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.
 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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

从官网上pull镜像ubuntu,并以交互的方式运行

root@apple:/home/kevin/docker# docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
e0a742c2abfd: Pull complete 
486cb8339a27: Pull complete 
dc6f0d824617: Pull complete 
4f7a5649a30e: Pull complete 
672363445ad2: Pull complete 
Digest: sha256:84c334414e2bfdcae99509a6add166bbb4fa4041dc3fa6af08046a66fed3005f
Status: Downloaded newer image for ubuntu:latest
root@93a1b9d39683:/#
root@93a1b9d39683:/#
root@93a1b9d39683:/#
root@93a1b9d39683:/#
root@93a1b9d39683:/
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值