1.Docker容器概述
- 区分Docker容器技术和VM虚拟机技术:
Docker容器技术 [Container]:容器虚拟化技术
VM虚拟机技术[Virtual Machine]:传统虚拟化技术
主要区别是:
* [1] 容器提供了基于进程的隔离,而虚拟机提供了资源的完全隔离。
* [2] 虚拟机可能需要一分钟来启动,而容器只需要一秒钟或更短。
* [3] 容器使用宿主操作系统的内核,而虚拟机使用独立的内核
- 容器的好处
1.2.0 容器 - Docker容器发行版本:
Docker CE(社区版):免费开源版本-Docker Engine
Docker EE(企业版):商用收费版本-Docker Data Center - Docker容器安装环境:
公有云环境:基于阿里云以及腾讯云主机等安装Docker
私有云环境:基于自主主机环境安装Docker - Docker 平台的基本构成:
Docker 平台基本上由三部分组成:
- [1] 客户端:用户使用 Docker 提供的工具(CLI 以及 API 等)来构建,上传镜像并发布命令来创建和启动容器Docker
- [2] 主机:从 Docker registry 上下载镜像并启动容器Docker
- [3] registry:Docker 镜像仓库,用于保存镜像,并提供镜像上传和下载后面的文章会具体分析。
2.Docker容器部署与安装
Docker容器部署
查看 Centos7 开发环境:cat /etc/centos-release
[root@centos-amber ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)
[root@centos-amber ~]#
查看 Centos7 内核版本:uname -a 或者 cat /proc/version
[root@centos-amber ~]# uname -a
Linux centos-amber 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@centos-amber ~]#
在增加Docker阿里云yum源之前需要执行基础组件安装以及卸载历史版本:
基础组件安装:yum -y install gcc & yum -y install gcc-c++
#gcc 环境安装
yum -y install gcc
yum -y install gcc-c++
卸载历史版本:yum -y remove docker docker-common docker-selinux docker-engine
[root@centos-amber ~]# yum -y remove docker docker-common docker-selinux docker-engine
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-common
No Match for argument: docker-selinux
No Match for argument: docker-engine
No Packages marked for removal
[root@centos-amber ~]#
或者 删除已安装的Docker
# Uninstall installed docker
[root@centos-amber ~]# sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-selinux \
> docker-engine-selinux \
> docker-engine
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-client
No Match for argument: docker-client-latest
No Match for argument: docker-common
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-selinux
No Match for argument: docker-engine-selinux
No Match for argument: docker-engine
No Packages marked for removal
[root@centos-amber ~]#
Ps: Docker部署要求64位的系统且内核版本至少为3.10
2.0.2 部署Docker添加yum源:yum install epel-release –y && yum list
[root@centos-amber ~]# yum install epel-release –y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package epel-release-7-11.noarch already installed and latest version
Nothing to do
[root@centos-amber ~]#
[root@centos-amber ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up list of fastest mirrors
[root@centos-amber ~]# yum list
2.1 Docker容器安装
配置阿里云Docker Yum源
- [1] Set up repository :
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
[root@centos-amber docker]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
.............
[root@centos-amber docker]#
- [2] Use Aliyun Docker
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@centos-amber docker]# sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://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@centos-amber docker]#
更新Yum缓存:sudo yum -y makecache fast
[root@centos-amber ~]# sudo yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/x86_64/primary_db | 32 kB 00:00:00
Metadata Cache Created
[root@centos-amber ~]# sudo yum -y makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Metadata Cache Created
[root@centos-amber ~]#
查看对应版本:yum list docker-ce --showduplicates
[root@centos-amber docker]# yum list docker-ce --showduplicates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/x86_64/primary_db | 32 kB 00:00:00
Available Packages
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
[root@centos-amber docker]#
2.1.3 安装Docker最新版本: sudo yum install docker-ce
docker-ce-cli 或者 yum install docker-io –y
[root@centos-amber docker]# sudo yum install docker-ce
..............
Installed:
docker-ce.x86_64 3:19.03.1-3.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.4-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.107-1.el7_6 containerd.io.x86_64 0:1.2.6-3.3.el7 docker-ce-cli.x86_64 1:19.03.1-3.el7
libcgroup.x86_64 0:0.41-20.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-29.el7_6.1 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
Complete!
[root@centos-amber docker]#
2.1.4 启动Docker服务:
# Start docker service
systemctl enable docker
systemctl start docker
执行:systemctl enable docker 允许开机启动
[root@centos-amber docker]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@centos-amber docker]#
执行:systemctl start docker 启动Docker服务
[root@centos-amber docker]# systemctl start docker
[root@centos-amber docker]#
基本命令:
systemctl enable docker # 允许开机启动
systemctl start docker #运行Docker守护进程
systemctl stop docker #停止Docker守护进程
systemctl restart docker #重启Docker守护进程
systemctl status docker #查看Docker的运行状态
2.1.5 检验安装Docker服务信息:
执行:docker info 查看Docker服务信息
[root@centos-amber docker]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.27.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.795GiB
Name: centos-amber
ID: TS7V:P2HE:MICX:JPN7:H5JU:PQX5:JWB3:4YSO:DM7X:RVBV:URME:64DZ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
[root@centos-amber docker]#
执行:docker version 查看版本号
[root@centos-amber docker]# docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:07 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:19:36 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683
[root@centos-amber docker]#
3. Docker配置阿里云镜像加速器
Docker 密码:Docker20190822
阿里云官网配置:
sudo mkdir -p /etc/docker sudo
tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://j98vrcq8.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
编辑配置文件:vim /etc/docker/daemon.json
[root@centos-amber docker]#vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://j98vrcq8.mirror.aliyuncs.com"]
}
[root@centos-amber docker]# sudo systemctl daemon-reload
[root@centos-amber docker]# sudo systemctl restart docker
[root@centos-amber docker]#
[root@centos-amber docker]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.27.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.795GiB
Name: centos-amber
ID: TS7V:P2HE:MICX:JPN7:H5JU:PQX5:JWB3:4YSO:DM7X:RVBV:URME:64DZ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://j98vrcq8.mirror.aliyuncs.com/
Live Restore Enabled: false
[root@centos-amber docker]#
4.Docker容器基本组件部署与安装
Compose组件部署与安装
基本概述:
Docker Compose是一个用来定义和运行复杂应用的Docker工具。
一个使用Docker容器的应用,通常由多个容器组成。
使用Docker Compose不再需要使用shell脚本来启动容器。
Compose 通过一个配置文件来管理多个Docker容器,在配置文件中,所有的容器通过services来定义。然后使用docker-compose脚本来启动,停止和重启应用,和应用中的服务以及所有依赖服务的容器,非常适合组合使用多个容器进行开发的场景
安装docker-compose的方式:
- [1] 从github上下载docker-compose二进制文件安装
下载最新版的docker-compose文件 :
sudo curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-uname -s
-uname -m
-o /usr/local/bin/docker-compose
[root@centos-amber ~]# sudo curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 640 0 --:--:-- --:--:-- --:--:-- 640
3 16.1M 3 645k 0 0 1669 0 2:48:53 0:06:35 2:42:18 0
curl: (56) TCP connection reset by peer
[root@centos-amber ~]#
添加可执行权限: sudo chmod +x /usr/local/bin/docker-compose
[root@centos-amber ~]# sudo chmod +x /usr/local/bin/docker-compose
[root@centos-amber ~]#
卸载docker-compose执行:sudo rm /usr/local/bin/docker-compose
[root@centos-amber ~]# sudo rm /usr/local/bin/docker-compose
[root@centos-amber ~]#
- [2] 使用pip install命令安装:
安装方式:sudo pip install docker-compose
sudo pip install docker-compose
卸载方式:pip uninstall docker-compose
pip uninstall docker-compose
2种方式检验安装结果:docker-compose --version
[root@centos-amber ~]# docker-compose --version
/usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version!
RequestsDependencyWarning)
docker-compose version 1.24.1, build 4667896
[root@centos-amber ~]#
docker-compose基础命令:
01.启动所有服务: docker-compose up
docker-compose up
02.查看容器进程: docker-compose ps
docker-compose ps
03.查看容器帮助: docker-compose -h
docker-compose -h
04.停止和删除容器、网络、卷、镜像: docker-compose down
docker-compose down
05.打印容器服务: docker-compose logs
docker-compose logs
06.构建容器服务: docker-compose build
docker-compose build
07.拉取镜像服务: docker-compose pull
docker-compose pull
08.重启容器服务: docker-compose restart
docker-compose restart
09.停止容器服务: docker-compose stop
docker-compose stop
10.启动容器服务: docker-compose start
docker-compose start
11.运行容器服务: docker-compose run
docker-compose run
12.删除容器服务: docker-compose rm
docker-compose rm
13.设置指定服务运行的容器个数: docker-compose scale
docker-compose scale
14.暂停容器服务: docker-compose pause
docker-compose pause
15.强制停止容器服务: docker-compose kill
docker-compose kill
16.验证并查看compose文件配置: docker-compose config
docker-compose config
17.创建容器服务: docker-compose create
docker-compose create
18.显示容器端口所映射的公共端口: docker-compose port
docker-compose port
19.推送服务依赖的镜像: docker-compose push
docker-compose push
20.暂停容器服务: docker-compose pause
docker-compose pause
21.恢复处于暂停状态中的服务: docker-compose unpause
docker-compose unpause
22.打印Docker版本信息: docker-compose version
docker-compose version
ps[注意事项]:
[1]./usr/lib/python2.7/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version!
[root@centos-amber ~]# docker-compose version
/usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version!
RequestsDependencyWarning)
docker-compose version 1.24.1, build 4667896
docker-py version: 3.7.3
CPython version: 2.7.5
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
解决方案:
1.输入命令卸载urllib3: pip uninstall urllib3
[root@centos-amber ~]# pip uninstall urllib3
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Uninstalling urllib3-1.22:
Would remove:
/usr/lib/python2.7/site-packages/urllib3-1.22.dist-info/*
/usr/lib/python2.7/site-packages/urllib3/*
Proceed (y/n)? y
Successfully uninstalled urllib3-1.22
[root@centos-amber ~]#
2.输入命令卸载chardet:pip uninstall chardet
[root@centos-amber ~]# pip uninstall chardet
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Uninstalling chardet-3.0.4:
Would remove:
/usr/bin/chardetect
/usr/lib/python2.7/site-packages/chardet-3.0.4.dist-info/*
/usr/lib/python2.7/site-packages/chardet/*
Would not remove (might be manually added):
/usr/lib/python2.7/site-packages/chardet/chardetect.py
/usr/lib/python2.7/site-packages/chardet/chardetect.pyo
/usr/lib/python2.7/site-packages/chardet/constants.py
/usr/lib/python2.7/site-packages/chardet/constants.pyo
Proceed (y/n)? y
Successfully uninstalled chardet-3.0.4
[root@centos-amber ~]#
3.安装输入requests:pip install requests
[root@centos-amber ~]# pip install requests
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: requests in /usr/lib/python2.7/site-packages (2.18.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python2.7/site-packages (from requests) (2017.7.27.1)
Collecting chardet<3.1.0,>=3.0.2
Downloading http://mirrors.aliyun.com/pypi/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
|████████████████████████████████| 143kB 1.2MB/s
Requirement already satisfied: idna<2.7,>=2.5 in /usr/lib/python2.7/site-packages (from requests) (2.6)
Collecting urllib3<1.23,>=1.21.1
Downloading http://mirrors.aliyun.com/pypi/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl (132kB)
|████████████████████████████████| 133kB 63.1MB/s
Installing collected packages: chardet, urllib3
Found existing installation: chardet 2.2.1
Uninstalling chardet-2.2.1:
Successfully uninstalled chardet-2.2.1
Successfully installed chardet-3.0.4 urllib3-1.22
[root@centos-amber ~]# docker-compose version
docker-compose version 1.24.1, build 4667896
docker-py version: 3.7.3
CPython version: 2.7.5
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
[root@centos-amber ~]#
Machine组件部署与安装
基本概述:
Docker Machine是一个工具,可让您在虚拟主机上安装Docker Engine,并使用docker-machine命令管理主机。
安装docker-compose的方式:
curl -L https://github.com/docker/machine/releases/download/v0.16.1/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
Docker 与宿主机建立网络通信:
ps1 :docker 端口映射错误
docker: Error response from daemon: driver failed programming external connectivity on endpoint mysql-master (1aac2f09e8d851518f8551308ccbe1e036454d5103bd99fba3f7b3870e3b21b4): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3307 -j DNAT --to-destination 172.17.0.4:3306 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
解决办法:
- [1] 执行:pkill docker
- [2] iptables -t nat -F
- [3] ifconfig docker0 down
- [4] brctl delbr docker0
pkill docker && iptables -t nat -F && ifconfig docker0 down && brctl delbr docker0
ps2: linux brctl command not found
[root@centos-meteor ~]# brctl delbr docker0
-bash: brctl: command not found
宿主机安装: yum install bridge-utils
portainer组件部署
搜索镜像:docker search portainer
[root@centos-amber ~]# docker search portainer
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
portainer/portainer Making Docker management easy. https://porta… 1340
portainer/agent An agent used to manage all the resources in… 44
portainer/templates App Templates for Portainer http://portainer… 15
lihaixin/portainer docker ui 7 [OK]
portainer/golang-builder Utility to build Golang binaries. 4 [OK]
greenled/portainer-stack-utils Bash scripts to deploy/undeploy stacks in a … 3 [OK]
portainerci/portainer Portainer images automatically created via P… 3
stefanscherer/portainer Portainer for Windows 1809 and some older In… 2
dockerframework/portainer Portainer (Simple Management UI for Docker) … 1 [OK]
j0nnylester/portainer portainer running on a Raspberry Pi 1
hassioaddons/portainer 1
portainer/base Multi-stage build image to create the Portai… 1 [OK]
softonic/portainer-endpoint Allows auto register all the swarm nodes in … 1 [OK]
hassioaddons/portainer-amd64 0
rancher/portainer-agent 0
rodjers/portainer Swarm portainer 0
nenadilic84/portainer 0
hassioaddons/portainer-armv7 0
11384eb/portainer 0
helloysd/portainer 0
portainer/angular-builder Builder image for Portainer frontend. 0 [OK]
ssbkang/portainer 0
portainerci/agent Portainer agent images automatically created… 0
ollijanatuinen/portainer debug/development versions of portainer 0
hassioaddons/portainer-aarch64 0
[root@centos-amber ~]#
ps:错误1:Error response from daemon
[root@centos-amber ~]# docker search portainer
Error response from daemon: Get https://index.docker.io/v1/search?q=portainer&n=25: dial tcp: lookup index.docker.io: no such host
原因分析: 配置加速后没有重启Docker
[root@centos-amber ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
拉取镜像:docker pull portainer/portainer
[root@centos-amber ~]# docker pull portainer/portainer
Using default tag: latest
latest: Pulling from portainer/portainer
d1e017099d17: Pull complete
7585cb582294: Pull complete
Digest: sha256:497e7cb961cec56a39134f0b106d44bdf0500bd58914cd89582e3c93e5b75d67
Status: Downloaded newer image for portainer/portainer:latest
docker.io/portainer/portainer:latest
[root@centos-amber ~]#
修改镜像名称:docker tag docker.io/portainer/portainer:latest portainer:latest
[root@centos-amber ~]# docker tag docker.io/portainer/portainer:latest portainer:latest
[root@centos-amber ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
portainer latest 4cda95efb0e4 13 days ago 80.6MB
portainer/portainer latest 4cda95efb0e4 13 days ago 80.6MB
[root@centos-amber ~]#
开放端口:
[root@centos-amber ~]# systemctl start firewalld
[root@centos-amber ~]# firewall-cmd --zone=public --add-port=9000/tcp --permanent
success
[root@centos-amber ~]# firewall-cmd --reload
success
[root@centos-amber ~]# firewall-cmd --list-ports
9000/tcp
[root@centos-amber ~]# systemctl stop firewalld
[root@centos-amber ~]#
部署portainer:
docker run -ti -d --name portainer-server -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
[root@centos-amber ~]# docker run -ti -d --name portainer-server -p 9000:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock portainer:latest
306aac709b44e2275ead86dffc9b9f7889c5d6b58f9a0d73c7a749ec4262cc45
[root@centos-amber ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
306aac709b44 portainer "/portainer" 7 seconds ago Up 6 seconds 0.0.0.0:9000->9000/tcp portainer-server
[root@centos-amber ~]#
打开浏览器:http://127.0.0.1:9000,配置用户名和密码:
5.Docker容器部署与安装总结
docker 配置基于阿里云的Yum源:
- [1] 安装必要的系统工具 :sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- [2] 添加软件源信息:sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- [3] 更新并安装 Docker-CE: sudo yum makecache fast sudo yum -y install docker-ce
sudo yum makecache fast
sudo yum -y install docker-ce
- [4] 开启Docker服务: systemctl enable docker systemctl start docker
systemctl enable docker
systemctl start docker
docker 部署安装以及基本命令使用:
- [1] Docker部署要求64位的系统且内核版本至少为3.10
- [2] Docker安装目录:var/lib/docker 和 /var/lib/docker-engine
- [3] Docker配置目录:/etc/docker