Docker里安装centos8镜像

拉取centos8镜像

如果觉得慢记得换源

1
2
3
4
5
6
7
{
"debug": true,
"experimental": false,
"registry-mirrors": [
"https://9cpn8tt6.mirror.aliyuncs.com"
]
}

拉取Centos8.2.2

1
docker pull centos:8.2.2004

image-20201122002702333

Centos版本

1
cat /etc/redhat-release

image-20201122002131126

获取IMAGE ID

1
docker images

image-20201122002742593

启动镜像centos8

如果不指定 /bin/bash,容器运行后会自动停止

1
docker run -d -i -t <IMAGE ID> /bin/bash

image-20201122002907469

获取CONTAINER ID

1
docker ps

image-20201122002955999

进入容器

1
docker exec -it <CONTAINER ID> bash

image-20201122003029517

进入后发现没有ifconfig

image-20201122003044455

yum安装

1
yum install -y net-tools

如果觉得慢,可以换阿里源

1
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

image-20201122003220008

效果爆棚

image-20201122003425530