docker在线安装

一个完整的Docker有以下几个部分组成:
DockerClient客户端
Docker Daemon守护进程
Docker Image镜像
DockerContainer容器

官方网站:https://www.docker.com/

docker操作手册:https://docs.docker.com/engine/install/centos/

 1.安装之前现在服务器上原有的docker

yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine

结果:

No Match for argument: docker

2.安装docker需要的依赖

这一步可以跟官方网站安装的操作手册一致

yum install -y yum-utils

结果:

以下结果代表该服务器已经安装最新的依赖了

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * epel: hkg.mirror.rackspace.com
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do

3.设置镜像仓库地址:

官网地址:

本地使用没成功,建议使用下面的阿里云的

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

阿里云镜像仓库地址:

 yum-config-manager \
  --add-repo \
   http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4.安装docker相关引擎

我们这里安装的是ce版本是免费的社区版本,ee是企业版本收费比较贵

 	yum makecache fase 
yum install docker-ce docker-ce-cli containerd.io

5.启动运行docker

systemctl  start  docker

6.查看docker版本

docker version

结果:

Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.7
 Git commit:        baeda1f
 Built:             Tue Oct 25 18:04:24 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.7
  Git commit:       3056208
  Built:            Tue Oct 25 18:02:38 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.10
  GitCommit:        770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

7.使用最经典的hello,world进行测试是否执行成功

docker run hello-world

结果:

Unable to find image 'hello-world:latest' locally    运行hello-world镜像
latest: Pulling from library/hello-world             没有在本地找到hello-world镜像
2db29710123e: Pull complete                          使用pull远程在官方拉取hello-world镜像


Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
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/

8.docker run运行思维导图

9.查看本机有哪些docker镜像

docker images

 结果:

可以看到刚才在执行docker run hello-world的时候,已经将hello-world镜像拉去到本地镜像中了

REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    feb5d9fea6a5   14 months ago   13.3kB

10.如何卸载docker

yum  remove docker-ce docker-ce-cli containerd.io

删除资源

rm -rf  /var/lib/docker 

注意:/var/lib/docker 为docker默认的工作路径!

11.使用阿里云加速
#登录阿里云找到容器服务

在这里插入图片描述

#找到镜像加速器地址,每个阿里云用户的镜像加速地址都不一样

 

配置使用:

mkdir -p /etc/docker

tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://kskdqwg1.mirror.aliyuncs.com"]
}
EOF

 systemctl daemon-reload
 systemctl restart docker

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ELIAUK``

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值