赞
踩
1,安装docker
a,切换到yum目录
[root@docker ~]# cd /etc/yum.repos.d/
b,yum repolist
[root@docker yum.repos.d]# yum repolist
网站链接:https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/
c,wget docker-ce:
[root@docker yum.repos.d]# wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
--2019-09-27 15:02:18-- https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2424 (2.4K) [application/octet-stream]
正在保存至: “docker-ce.repo”
100%[=============================================================================================================================>] 2,424 --.-K/s 用时 0s
2019-09-27 15:02:21 (11.5 MB/s) - 已保存 “docker-ce.repo” [2424/2424])
[root@docker yum.repos.d]#
d,修改docker-ce:
[root@docker yum.repos.d]# vi docker-ce.repo
改为链接为清华镜像库的:https://mirrors.tuna.tsinghua.edu.cn/docker-ce
:%s@https://download.docker.com/@https://mirrors.tuna.tsinghua.edu.cn/docker-ce/@
e,查看是否有程序包:
"docker-ce.repo" 83L, 2880C written [root@docker yum.repos.d]# yum repolist 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.sjtu.edu.cn * extras: ftp.ksu.edu.tw * updates: centos.cs.nctu.edu.tw docker-ce-stable | 3.5 kB 00:00:00 (1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:02 (2/2): docker-ce-stable/x86_64/primary_db | 34 kB 00:00:03 源标识 源名称 状态 base/7/x86_64 CentOS-7 - Base 10,097 docker-ce-stable/x86_64 Docker CE Stable - x86_64 56 extras/7/x86_64 CentOS-7 - Extras 304 updates/7/x86_64 CentOS-7 - Updates 319 repolist: 10,776 [root@docker yum.repos.d]#
f,安装docker-ce
[root@docker docker]# yum install docker -y
g,添加阿里云加速器
[root@docker yum.repos.d]# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://lptjipx8.mirror.aliyuncs.com"]
}
h,启动docker
[root@docker docker]# systemctl restart docker
[root@docker docker]# systemctl enable docker
2,使用docker
a,在网上拉取镜像
[root@docker ~]# docker pull nginx
Using default tag: latest
Trying to pull repository docker.io/library/nginx ...
latest: Pulling from docker.io/library/nginx
b8f262c62ec6: Pull complete
e9218e8f93b1: Pull complete
7acba7289aa3: Pull complete
Digest: sha256:aeded0f2a861747f43a01cf1018cf9efe2bdd02afd57d2b11fcc7fcadc16ccd1
Status: Downloaded newer image for docker.io/nginx:latest
b,查看镜像:
anaconda-ks.cfg
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx latest f949e7d76d63 2 days ago 126 MB
[root@docker ~]#
c,运行容器
[root@docker ~]# docker run -itd --name box busybox:latest
8234140bce2670116000b089a008c34622f33bbd539c3c3107bee1c464bdd44b
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8234140bce26 busybox:latest "sh" 4 seconds ago
d,与宿主机交互
[root@docker ~]# docker run -itd -P --name nginx nginx:latest
ef5b9dc34138ea2e3d495faead86700636a7743b3e2aef4ac63d33caa26efa44
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef5b9dc34138 nginx:latest "nginx -g 'daemon ..." 4 seconds ago Up 2 seconds 0.0.0.0:32768->80/tcp nginx
bca1348b8edf busybox:latest "sh" 39 seconds ago Up 38 seconds box
[root@docker ~]#
’
e,访问
http://192.168.200.66:32768/
3,部署UI界面
[root@docker ~]# docker run -itd --restart=always -p 9000:9000 -v /var/run/docker.sock:/docker.sock --name dockerui abh1nav/dockerui:latest -e="/docker.sock"
访问:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。