[工具] Docker安装及portainer GUI

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

[工具] Docker安装及portainer GUI

风间悠香   2020-03-01 我要评论

一、Docker Engine安装

1.安装流程

1)移除旧版本(如果有旧版本)

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
rm -rf /etc/systemd/systemhttps://img.qb5200.com/download-x/docker.service.d
rm -rf /var/libhttps://img.qb5200.com/download-x/docker
rm -rf /var/runhttps://img.qb5200.com/download-x/docker
rm -rf /usr/localhttps://img.qb5200.com/download-x/docker
rm -rf /etchttps://img.qb5200.com/download-x/docker

2)安装必要的系统工具

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

3)添加aliyun的源

yum-config-manager --add-repo http://mirrors.aliyun.comhttps://img.qb5200.com/download-x/docker-ce/linux/centoshttps://img.qb5200.com/download-x/docker-ce.repo
yum clean all
yum makecache fast

4)安装docker-ce

yum -y install docker-ce

5)启动服务

systemctl start docker
# 开机自动启动
systemctl enable docker

6)测试运行docker

docker run hello-world

2.更新docker国内仓库

1)修改或创建daemon.json配置文件

# vi /etchttps://img.qb5200.com/download-x/dockerhttps://img.qb5200.com/download-x/daemon.json
{
    "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

2)重启服务

systemctl restart docker

3)其他国内镜像

Docker中国区官方镜像
https://registry.docker-cn.com

ustc 
https:/https://img.qb5200.com/download-x/docker.mirrors.ustc.edu.cn
 
中国科技大学
https:/https://img.qb5200.com/download-x/docker.mirrors.ustc.edu.cn

阿里云容器  服务
https://cr.console.aliyun.com/
首页点击“创建我的容器镜像”  得到一个专属的镜像加速地址,类似于“https://1234abcd.mirror.aliyuncs.com”

4)测试

docker run -itd centos /bin/bash
[root@myserver ~]# docker ps
CONTAINER ID        IMAGE              COMMAND            CREATED              STATUS              PORTS              NAMES
f57d4703adc3        centos              "/bin/bash"        About a minute ago  Up About a minute                      jolly_dhawan
[root@myserver ~]# docker exec -it f57d4703adc3 /bin/bash
[root@f57d4703adc3 /]#
[root@f57d4703adc3 /]# cat /etc/RedHat-release
CentOS Linux release 7.6.1810 (Core)
[root@f57d4703adc3 /]#

二、安装和使用Portainer GUI

1.搜索portainer镜像

[root@centos7 ~]# docker search portainer
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
portainer/portainer              Making Docker management easy. http://porta鈥  1573                                    
portainer/agent                  An agent used to manage all the resources in鈥  54                                      
portainer/templates              App Templates for Portainer http://portainer鈥  17                                      
lihaixin/portainer               docker ui                                       11                                      [OK]
portainerci/portainer            Portainer images automatically created via P鈥  4                                       
portainer/golang-builder         Utility to build Golang binaries.               4                                       [OK]
greenled/portainer-stack-utils   Bash scripts to deploy/undeploy stacks in a 鈥  3                                       [OK]
portainer/base                   Multi-stage build image to create the Portai鈥  2                                       [OK]
stefanscherer/portainer          Portainer for Windows 1809 and some older In鈥  2                                       
hassioaddons/portainer                                                           1                                       
softonic/portainer-endpoint      Allows auto register all the swarm nodes in 鈥  1                                       [OK]
j0nnylester/portainer            portainer running on a Raspberry Pi             1                                       
11384eb/portainer                                                                0                                       

2.拉取portainer的image

docker pull portainer/portainer

3.运行Portainer

1)运行之前先关闭selinux

selinux sed -i '/SELINUX/s/enforcinghttps://img.qb5200.com/download-x/disabled/g' /etc/selinux/config

2)为portainer创建一个volume(也可以不创建)

docker volume create portainer_volume

3)启动portainer容器

docker run --name=my_portainer -d -p 9001:9001 -v /var/runhttps://img.qb5200.com/download-x/docker.sock:/var/runhttps://img.qb5200.com/download-x/docker.sock -v portainer_volume:https://img.qb5200.com/download-x/data portainer/portainer

该容器命名为my_portainer,将容器中portainer默认端口9000,映射到宿主机端口9001,使用socket映射 /var/runhttps://img.qb5200.com/download-x/docker.sock:/var/runhttps://img.qb5200.com/download-x/docker.sock,指定volume映射(即将portainer_volume对应的宿主机目录挂载到容器的https://img.qb5200.com/download-x/data目录),容器基于portainer/portainer镜像启动。

4.使用portainer

1)使用浏览器访问http://宿主机IP:9001

第一次登陆,会让我们设置密码。

2)选择local模式

 

由于portainer支持local、remote、agent等形式来管理docker容器。我们这里是为了管理本地的docker容器,所以选择第一个local。

如果要管理其他机器的docker容器,或者docker集群,则可以选择后面的对应模式。

3)查看我们管理下的endpoint

 

portainer可以同时管理多个endpoints,包括本地或远程的。这里我们只有本地的endpoint。

4)查看endpoint中所有的信息

点击local endpoint进入管理页面:

 

可以看到该页面包含该endpoint几乎所有的信息,其中有镜像信息、容器信息、容器网络、volume等,并且提供操作。(有时候可能操作会报错,这时再去CMD中操作就可以了)

 

###

 

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们