CentOS 7.7 下安装Docker

一、安装Docker-CE

yum remove -y docker docker-client docker-client-latest docker-common docker-latest  docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine

yum install -y yum-utils device-mapper-persistent-data lvm2

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

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

wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-1.el7_6.noarch.rpm

# 以下2个安装包在CentOS 7.7光盘镜像里:
rpm -ivh selinux-policy-3.13.1-229.0.1.el7.noarch.rpm
rpm -ivh selinux-policy-targeted-3.13.1-229.0.1.el7.noarch.rpm
rpm -ivh container-selinux-2.107-1.el7_6.noarch.rpm

yum -y install selinux-policy selinux-policy-base selinux-policy-targeted policycoreutils-python

wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse3-libs-3.6.1-4.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/slirp4netns-0.4.3-4.el7_8.x86_64.rpm

rpm -ivh fuse3-libs-3.6.1-4.el7.x86_64.rpm
rpm -ivh fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
rpm -ivh slirp4netns-0.4.3-4.el7_8.x86_64.rpm

yum makecache fast
yum -y install docker-ce
systemctl start docker
systemctl enable docker

以上rpm软件打包下载地址:http://soft.yjsec.com/docker.rpm.tar.gz

二、配置国内镜像站

vi /etc/docker/daemon.json
# 添加如下内容:
{
  "experimental": false,
  "registry-mirrors": [
    "https://6kx4zyno.mirror.aliyuncs.com"
  ],
  "debug": true
}

# 重新启动docker服务后生效:
systemctl stop docker
systemctl start docker

其他镜像站:
- 中科院的镜像:"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
- 阿里云的镜像:"registry-mirrors":["https://6kx4zyno.mirror.aliyuncs.com"]
- 七牛云加速器:https://reg-mirror.qiniu.com
- 网易:https://hub-mirror.c.163.com/

三、安装 HTML5 Speedtest

[root@localhost ~]# docker pull ilemonrain/html5-speedtest
Using default tag: latest
latest: Pulling from ilemonrain/html5-speedtest
ff3a5c916c92: Pull complete 
870adc461363: Pull complete 
4ecbd014d679: Pull complete 
ceb07adb8522: Pull complete 
a4a1a6dec3dd: Pull complete 
Digest: sha256:e1553610a0e40c66ab7ed31a8df2a109b3df5572a36c849ec0854ff88cda8e87
Status: Downloaded newer image for ilemonrain/html5-speedtest:latest
docker.io/ilemonrain/html5-speedtest:latest

[root@localhost ~]# docker image ls
REPOSITORY                   TAG       IMAGE ID       CREATED       SIZE
ilemonrain/html5-speedtest   latest    ce556509223b   2 years ago   26.9MB
ilemonrain/html5-speedtest   alpine    cfdaa77e647d   2 years ago   26.9MB

[root@localhost ~]# docker rmi -f ce556509223b
Untagged: ilemonrain/html5-speedtest:latest
Untagged: ilemonrain/html5-speedtest@sha256:e1553610a0e40c66ab7ed31a8df2a109b3df5572a36c849ec0854ff88cda8e87
Deleted: sha256:ce556509223b3ba82ca35b099f55bfd7a9b75e34e2da85df56c77a8b98b23b20

[root@localhost ~]# docker rmi -f cfdaa77e647d
Untagged: ilemonrain/html5-speedtest:alpine
Untagged: ilemonrain/html5-speedtest@sha256:b154819e04a8c403372e996122744f5b081411ad0921dd92ae74b88a5afc07e1
Deleted: sha256:cfdaa77e647d754bef0722926412a81c29f6a5fbc16c1544b73fd6ae3bbe9e4e

[root@localhost ~]# docker pull ilemonrain/html5-speedtest
Using default tag: latest
latest: Pulling from ilemonrain/html5-speedtest
Digest: sha256:e1553610a0e40c66ab7ed31a8df2a109b3df5572a36c849ec0854ff88cda8e87
Status: Downloaded newer image for ilemonrain/html5-speedtest:latest
docker.io/ilemonrain/html5-speedtest:latest

[root@localhost ~]# docker run -d -p 8089:80 ilemonrain/html5-speedtest
996fb04756ef48192a0aee512fb1f7aece027efa6dfac50b3a4752bf01043e24
[root@localhost ~]# docker ps 
CONTAINER ID   IMAGE                        COMMAND               CREATED         STATUS         PORTS                  NAMES
996fb04756ef   ilemonrain/html5-speedtest   "sh /entrypoint.sh"   6 seconds ago   Up 5 seconds   0.0.0.0:8089->80/tcp   naughty_allen

四、安装RabbitMQ

[root@localhost ~]# docker pull rabbitmq:3-management
3-management: Pulling from library/rabbitmq
f22ccc0b8772: Pull complete 
3cf8fb62ba5f: Pull complete 
e80c964ece6a: Pull complete 
c1d2d6c5864b: Pull complete 
a1d14468c24f: Pull complete 
ac5224ea1eb3: Pull complete 
8da622546a6c: Pull complete 
5f20211ad28c: Pull complete 
553fbbbec0d8: Pull complete 
87e159513515: Pull complete 
e7ad102c950f: Pull complete 
fc664c88ed06: Pull complete 
4c05edd7de3b: Pull complete 
Digest: sha256:83fb3d109a3775bd8bc38629864bf54c074c41c5e34b608987b0b524ba707aff
Status: Downloaded newer image for rabbitmq:3-management
docker.io/library/rabbitmq:3-management

[root@localhost ~]#  docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
f9771405b5ff0c5d6f5315750da9ae3d60b4453295d45afa2e67bda7c3921093

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS          PORTS                                                                                                         NAMES
f9771405b5ff   rabbitmq:3-management        "docker-entrypoint.s…"   18 seconds ago   Up 17 seconds   4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp   rabbitmq

五、windows下运行centos

PS C:\Users\xww20> docker pull centos
Using default tag: latest
latest: Pulling from library/centos
7a0437f04f83: Pull complete
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

PS C:\Users\xww20> docker run -d -p 22:22 --privileged centos:centos7 /usr/sbin/init
Unable to find image 'centos:centos7' locally
PS C:\Users\xww20> docker run -d -p 22:22 --privileged centos /usr/sbin/init
06b41215169ceab7baa20fd40cfdac018a4f3aab83f6f806f9eb1c91f58122c8

PS C:\Users\xww20> docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED         STATUS         PORTS
                                                         NAMES
06b41215169c   centos                  "/usr/sbin/init"         6 seconds ago   Up 3 seconds   0.0.0.0:22->22/tcp
                                                         hopeful_elion

PS C:\Users\xww20> docker exec -it 06b41215169c bash
[root@06b41215169c /]# cat /etc/redhat-release
CentOS Linux release 8.3.2011
[root@06b41215169c /]#
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注