docker部署
·
docker部署
1、关闭防火墙和selinux
[root@stw ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@stw ~]# getenforce
Disabled
2、安装网络源
[root@stw ~]# cd /etc/yum.repos.d/
[root@stw yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@stw yum.repos.d]# rm -rf *
[root@stw yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 7992 0 --:--:-- --:--:-- --:--:-- 8009
[root@stw yum.repos.d]# ls
CentOS-Base.repo
[root@stw yum.repos.d]# yum -y install epel-release
[root@stw yum.repos.d]# ls
CentOS-Base.repo epel.repo epel-testing.repo
3、对照开源镜像站的安装步骤进行安装
docker-ce镜像_docker-ce下载地址_docker-ce安装教程-阿里巴巴开源镜像站
(1)安装必要的一些系统工具
[root@stw yum.repos.d]# yum -y install yum-utils
(2)添加软件源信息(添加docker源)
[root@stw yum.repos.d]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@stw yum.repos.d]# ls
CentOS-Base.repo docker-ce.repo epel.repo epel-testing.repo
(3)安装docker(这里默认安装最新版本)
[root@stw yum.repos.d]# yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
(4)开启docker服务
[root@stw ~]# systemctl restart docker
[root@stw ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
(5)配置镜像加速器
加速器需要自己在阿里源官网申请一个账号,工作台-容器镜像服务-镜像工具-镜像加速器-----现在不能使用
使用以下加速器:
[root@stw ~]# vim /etc/docker/daemon.json
[root@stw ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
[root@stw ~]# systemctl daemon-reload
[root@stw ~]# systemctl restart docker
[root@stw ~]# docker --version
Docker version 26.1.4, build 5650f9b
(6)下载一些镜像(此步骤可忽略,docker已经部署完成)
[root@stw ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
d107e437f729: Pull complete
cb497a329a81: Pull complete
f1c4d397f477: Pull complete
f72106e86507: Pull complete
899c83fc198b: Pull complete
a785b80f5a67: Pull complete
6c50e4e0c439: Pull complete
Digest: sha256:d5f28ef21aabddd098f3dbc21fe5b7a7d7a184720bc07da0b6c9b9820e97f25e
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@stw ~]# docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
ce1261c6d567: Pull complete
aeb6d226161f: Pull complete
4f4fb700ef54: Pull complete
56926e6ce68f: Pull complete
4938babf7b43: Pull complete
307fcc49c641: Pull complete
Digest: sha256:027c678f36d3cd3dd2b44ad1e963e81be66f9eba065381c1126d3019fffeb01a
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest
[root@stw ~]# docker pull centos:7
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4
Status: Downloaded newer image for centos:7
docker.io/library/centos:7
[root@stw ~]# docker images //查看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 41f689c20910 6 weeks ago 192MB
httpd latest 65005131d37e 7 weeks ago 117MB
centos 7 eeb6ee3f44bd 4 years ago 204MB
更多推荐


所有评论(0)