Docker容器

Docker安装步骤

本文主要是介绍Docker安装步骤,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

官方步骤

1.配置好虚拟机(CentOS7及以上)且接外网

[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

2.卸载旧版本

(若之前没装过,此步省略)
/表示连接符而已

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

3. 下载安装gcc相关库

yum install -y gcc
yum install -y gcc-c++

4.安装需要的软件包

yum install -y yum-utils

5.设置stable镜像仓库

# 官方的(不推荐,国内网速不友好)
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 阿里云yyds
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6.更新yum软件包索引(可选)

yum makecache fast

7.安装Docker Engine

yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

8.启动docker

systemctl start docker
[[email protected] ~]# ps -df | grep docker
root       5768   5203  0 23:20 pts/1    00:00:00 grep --color=auto docker
[[email protected] ~]# ps -ef | grep docker
root       5649      1  1 23:20 ?        00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root       5770   5203  0 23:20 pts/1    00:00:00 grep --color=auto docker

9.测试

[[email protected] ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:05:12 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:03:33 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.7
  GitCommit:        0197261a30bf81f1ee8e6a4dd2dea0ef95d67ccb
 runc:
  Version:          1.1.3
  GitCommit:        v1.1.3-0-g6724737
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

10.卸载

systemctl stop docker

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

rm -rf /var/lib/docker

sudo rm -rf /var/lib/containerd

11.阿里云镜像加速

注:当然不一定要用阿里云的镜像,也可以用国内其它的镜像

注册阿里云账号——>控制台——>菜单——>容器镜像服务

个人学习,就选了个人实例

创建之后,点击镜像工具——>镜像加速器

这篇关于Docker安装步骤的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!