您的位置:首页 > 运维架构 > Docker

Docker-compose容器编排的使用Web项目架构(前台web数据和后台数据库以及负载均衡容器统一部署在一个容器中)

2019-06-24 14:54 1856 查看
Docker-compose容器编排的使用

首先贴上官方手册https://docs.docker.com/compose/install/ 学东西尽可能读官方手册

得有个问题引入:哈哈

** 随着容器使用得越发频繁,应用服务和容器间的关系更是复杂,
面对这种情况,研发部希望能使用更好的方法管理这些服务和对应的容器。工程师小w经过分析之后,决定使用集群来统一管理应用服务。
最近公司有个项目,需要将前台Web服务器和后台数据库,再加上负载均衡容器统一部署 在容器中,
研发部把这个项目交给了工程师小w面对这个任务,
小w决定使用Docker-compose容器编排服务,通过一-个单独的docker-compose.yml模板文件( YAML格式)为一个项目来定义一组相关联的应用容器。
**

1. Compose 简介
Compose的定位是“定义和运行多个Docker 容器的应用( Defining and runingnulti-container Docker Applications )",
其前身是开源项目Fig,目前仍然兼容Fig格式的模
板文件。
通过之前的介绍可以知道,使用一-
一个Dockerfile模板文件可以让用户很方便地定义一个单独的应用容器。
然而,在日常工作中,经常会碰到需要多个容器相互配合来完成某项任务的情况。
例如要实现一个Web项目,除了Web服务容器本身外,往往还需要加上后端的数据库服务容器,甚至还包括负载均衡容器等。
下图是Web项目架构示意图。
Compose恰好满足了这样的需求。
它允许用户通过一个单独的docker- compose.yml模板文件( YAML格式)来定义一组相关联的应 用容器为一个项目。
2. Compose中的service 和projectCompose中有两个重要的概念。

①服务( service ):一个应用的容器,实际上可以包括若干运行相同镜像的容器实例。
②项目(project): 由一组关联的应用容器组成的一一个完整业务单元,在docker- compose.yml文件中定义。
Coppose的默认管理对象是项目,可通过子命令对项目中的一组容器进行便捷的生命周期管理。

WEB项目架构示意图

Compose项目由Python编写,在实现上调用了Docker服务提供的API来对容器进行管理。
因此,只要所操作的平台支持Docker API,就可以在其上利用Compose来进行编排管理。
任务实施
1. 安装Compose
Compose目前支持Linux 和Mac OS平台,两者的安装过程大同小异。

安装Compose之前,要先安装Docker (需要Docker Engine 1.7.1+ ),可参考上一个博客介绍,https://blog.csdn.net/qq_28513801/article/details/93381492此外不再赘述。

Compose可以通过Python的pip工具进行安装,也可以直接下载编译好的二进制文牛进行使用,甚至可以直接运行在Docker容器中。
前两种方式是传统方式,适合在本地环境下安装使用;最后一种方式则不破坏系统不境,更适合云计算场景。
①安装Docker Compose (选择1.8.1 版本)。
[root@devops ~]#  yum install -y epel-release
[root@devops ~]# yum install -y python-pip
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: ftp.riken.jp
* extras: ap.stykers.moe
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-8.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
Package                            Arch                          Version                            Repository                   Size
=======================================================================================================================================
Installing:
python2-pip                        noarch                        8.1.2-8.el7                        epel                        1.7 M

Transaction Summary
=======================================================================================================================================
Install  1 Package

Total download size: 1.7 M
Installed size: 7.2 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/python2-pip-8.1.2-8.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for python2-pip-8.1.2-8.el7.noarch.rpm is not installed
python2-pip-8.1.2-8.el7.noarch.rpm                                                                              | 1.7 MB  00:00:14
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package    : epel-release-7-11.noarch (@extras)
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python2-pip-8.1.2-8.el7.noarch                                                                                      1/1
Verifying  : python2-pip-8.1.2-8.el7.noarch                                                                                      1/1

Installed:
python2-pip.noarch 0:8.1.2-8.el7

Complete!
[root@devops ~]#

如果提示Pip版本低的话就省级下
[root@devops ~]# pip install -U docker-compuse
Collecting docker-compuse
Could not find a version that satisfies the requirement docker-compuse (from versions: )
No matching distribution found for docker-compuse
You are using pip version 8.1.2, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@devops ~]# pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 176kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Successfully installed pip-19.1.1
[root@devops ~]#

我这里使用的是secureCRT 如果出现乱码 则我们设置一下字符编码

[root@devops ~]# pip install -U docker-compuse
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.
Collecting docker-compuse
ERROR: Could not find a version that satisfies the requirement docker-compuse (from versions: none)
ERROR: No matching distribution found for docker-compuse
[root@devops ~]# pip install -U docker-compose
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.
Collecting docker-compose
Downloading https://files.pythonhosted.org/packages/51/56/5745e66b33846e92a8814466c163f165a26fadad8b33afe381e8b6c3f652/docker_compose-1.24.0-py2.py3-none-any.whl (134kB)
|████████████████████████████████| 143kB 146kB/s
Collecting docker[ssh]<4.0,>=3.7.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/09/da/7cc7ecdcd01145e9924a8ccbe9c1baf3a362fc75d4cb150676eb5231ea60/docker-3.7.3-py2.py3-none-any.whl (134kB)
|████████████████████████████████| 143kB 219kB/s
Requirement already satisfied, skipping upgrade: backports.ssl-match-hostname>=3.5; python_version < "3.5" in /usr/lib/python2.7/site-packages (from docker-compose) (3.5.0.1)
Collecting requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/ff/17/5cbb026005115301a8fb2f9b0e3e8d32313142fe8b617070e7baad20554f/requests-2.20.1-py2.py3-none-any.whl (57kB)
|████████████████████████████████| 61kB 3.0MB/s
Requirement already satisfied, skipping upgrade: six<2,>=1.3.0 in /usr/lib/python2.7/site-packages (from docker-compose) (1.9.0)
Requirement already satisfied, skipping upgrade: PyYAML<4.3,>=3.10 in /usr/lib64/python2.7/site-packages (from docker-compose) (3.10)
Collecting texttable<0.10,>=0.9.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/02/e1/2565e6b842de7945af0555167d33acfc8a615584ef7abd30d1eae00a4d80/texttable-0.9.1.tar.gz
Collecting dockerpty<0.5,>=0.4.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/8d/ee/e9ecce4c32204a6738e0a5d5883d3413794d7498fe8b06f44becc028d3ba/dockerpty-0.4.1.tar.gz
Requirement already satisfied, skipping upgrade: ipaddress>=1.0.16; python_version < "3.3" in /usr/lib/python2.7/site-packages (from docker-compose) (1.0.16)
Collecting websocket-client<1.0,>=0.32.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/29/19/44753eab1fdb50770ac69605527e8859468f3c0fd7dc5a76dd9c4dbd7906/websocket_client-0.56.0-py2.py3-none-any.whl (200kB)
|████████████████████████████████| 204kB 224kB/s
Requirement already satisfied, skipping upgrade: enum34<2,>=1.0.4; python_version < "3.4" in /usr/lib/python2.7/site-packages (from docker-compose) (1.0.4)
Collecting docopt<0.7,>=0.6.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz
Collecting jsonschema<3,>=2.5.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/77/de/47e35a97b2b05c2fadbec67d44cfcdcd09b8086951b331d82de90d2912da/jsonschema-2.6.0-py2.py3-none-any.whl
Collecting cached-property<2,>=1.2.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/3b/86/85c1be2e8db9e13ef9a350aecd6dea292bd612fa288c2f40d035bb750ded/cached_property-1.5.1-py2.py3-none-any.whl
Collecting docker-pycreds>=0.4.0 (from docker[ssh]<4.0,>=3.7.0->docker-compose)
Downloading https://files.pythonhosted.org/packages/f5/e8/f6bd1eee09314e7e6dee49cbe2c5e22314ccdb38db16c9fc72d2fa80d054/docker_pycreds-0.4.0-py2.py3-none-any.whl
Collecting paramiko>=2.4.2; extra == "ssh" (from docker[ssh]<4.0,>=3.7.0->docker-compose)
Downloading https://files.pythonhosted.org/packages/17/9f/7430d1ed509e195d5a5bb1a2bda6353a4aa64eb95491f198a17c44e2075c/paramiko-2.5.0-py2.py3-none-any.whl (198kB)
|████████████████████████████████| 204kB 89kB/s
Collecting idna<2.8,>=2.5 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
|████████████████████████████████| 61kB 33kB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
|████████████████████████████████| 143kB 33kB/s
Collecting urllib3<1.25,>=1.21.1 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/01/11/525b02e4acc0c747de8b6ccdab376331597c569c42ea66ab0a1dbd36eca2/urllib3-1.24.3-py2.py3-none-any.whl (118kB)
|████████████████████████████████| 122kB 38kB/s
Collecting certifi>=2017.4.17 (from requests!=2.11.0,!=2.12.2,!=2.18.0,<2.21,>=2.6.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/69/1b/b853c7a9d4f6a6d00749e94eb6f3a041e342a885b87340b79c1ef73e3a78/certifi-2019.6.16-py2.py3-none-any.whl (157kB)
|████████████████████████████████| 163kB 46kB/s
Collecting functools32; python_version == "2.7" (from jsonschema<3,>=2.5.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/c5/60/6ac26ad05857c601308d8fb9e87fa36d0ebf889423f47c3502ef034365db/functools32-3.2.3-2.tar.gz
Collecting cryptography>=2.5 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<4.0,>=3.7.0->docker-compose)
Downloading https://files.pythonhosted.org/packages/e6/68/50698ce24c61db7d44d93a5043c621a0ca7839d4ef9dff913e6ab465fc92/cryptography-2.7-cp27-cp27mu-manylinux1_x86_64.whl (2.3MB)
|████████████████████████████████| 2.3MB 45kB/s
Collecting pynacl>=1.0.1 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<4.0,>=3.7.0->docker-compose)
Downloading https://files.pythonhosted.org/packages/b3/25/e605574f24948a8a53b497744e93f061eb1dbe7c44b6465fc1c172d591aa/PyNaCl-1.3.0-cp27-cp27mu-manylinux1_x86_64.whl (762kB)
|████████████████████████████████| 768kB 35kB/s
Collecting bcrypt>=3.1.3 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]<4.0,>=3.7.0->docker-compose)

②安装好以后更新pip工具

[root@devops ~]# pip install --upgrade pip
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.
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages (19.1.1)

也可以离线安装

1,运行此命令以下载Docker Compose的当前稳定版本:
[root@devops ~]# sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2.对二进制文件应用可执行权限:
sudo chmod +x /usr/local/bin/docker-compose

[root@devops ~]#  docker-compose --version
docker-compose version 1.24.0, build 1110ad01

下面是演示过程
[root@devops ~]# sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/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    645      0 --:--:-- --:--:-- --:--:--   646
100 15.4M  100 15.4M    0     0  48142      0  0:05:35  0:05:35 --:--:-- 48591
[root@devops ~]# chmod +x /usr/local/bin/docker-compose
[root@devops ~]# docker-compose --version
docker-compose version 1.24.0, build 0aa59064
[root@devops ~]#

下面开始进行我们的Compose案例

编写一个Python Web 案例 ,应用compose编排服务,案例包含两个容器、一个Python Web容器,一个是Redis数据库容器

①:
创建composeapp目录

[root@devops /]# mkdir composeapp
[root@devops /]# cd composeapp/
[root@devops composeapp]# touch Dockerfile
[root@devops composeapp]#

②:
编写Python程序
如果没有Redis和flask库的话 我们可以在Windows命令行中环境中安装一下
(这里建议在Windows下或者是Centos下的Pycharm中进行编写python程序,避免犯小错误)

C:\Users\WMM>pip install redis
Collecting redis
Downloading https://files.pythonhosted.org/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
|████████████████████████████████| 71kB 134kB/s
Installing collected packages: redis
Successfully installed redis-3.2.1

C:\Users\WMM>python
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 13:35:33) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

C:\Users\WMM>pip install flask
Collecting flask
Downloading https://files.pythonhosted.org/packages/9a/74/670ae9737d14114753b8c8fdf2e8bd212a05d3b361ab15b44937dfd40985/Flask-1.0.3-py2.py3-none-any.whl (92kB)
|████████████████████████████████| 92kB 3.5kB/s
Collecting Jinja2>=2.10 (from flask)
Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
|████████████████████████████████| 133kB 58kB/s
Collecting itsdangerous>=0.24 (from flask)
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Requirement already satisfied: Werkzeug>=0.14 in d:\python\python36\lib\site-packages (from flask) (0.14.1)
Requirement already satisfied: click>=5.1 in d:\python\python36\lib\site-packages (from flask) (7.0)
Requirement already satisfied: MarkupSafe>=0.23 in d:\python\python36\lib\site-packages (from Jinja2>=2.10->flask) (1.1.0)
Installing collected packages: Jinja2, itsdangerous, flask
Successfully installed Jinja2-2.10.1 flask-1.0.3 itsdangerous-1.1.0

也可以在linux下安装,避免缺少库

[root@devops composeapp]# pip install flask
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.
Collecting flask
Downloading https://files.pythonhosted.org/packages/9a/74/670ae9737d14114753b8c8fdf2e8bd212a05d3b361ab15b44937dfd40985/Flask-1.0.3-py2.py3-none-any.whl (92kB)
|████████████████████████████████| 92kB 6.3kB/s
Collecting Werkzeug>=0.14 (from flask)
Downloading https://files.pythonhosted.org/packages/9f/57/92a497e38161ce40606c27a86759c6b92dd34fcdb33f64171ec559257c02/Werkzeug-0.15.4-py2.py3-none-any.whl (327kB)
|████████████████████████████████| 327kB 5.3kB/s
Collecting click>=5.1 (from flask)
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
|████████████████████████████████| 81kB 5.4kB/s
Collecting itsdangerous>=0.24 (from flask)
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Jinja2>=2.10 (from flask)
Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
|████████████████████████████████| 133kB 6.1kB/s
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask)
Downloading https://files.pythonhosted.org/packages/fb/40/f3adb7cf24a8012813c5edb20329eb22d5d8e2a0ecf73d21d6b85865da11/MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: Werkzeug, click, itsdangerous, MarkupSafe, Jinja2, flask
Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.4 click-7.0 flask-1.0.3 itsdangerous-1.1.0
[root@devops composeapp]# pip install redis
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.
Collecting redis
Downloading https://files.pythonhosted.org/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
|████████████████████████████████| 71kB 93kB/s
Installing collected packages: redis
Successfully installed redis-3.2.1
[root@devops composeapp]#

开始编写Python的程序

app.py

[root@devops composeapp]# cat app.py
#coding:utf-8
from flask import Flask
from redis import Redis
import os

app = Flask(__name__)  #__XXX__ 在Python中表示系统定义的名字哦 __XXX 表示类中的私有变量名
## __init__ 构造函数的固定名称
redis = Redis(host="redis",port=6379)

@app.route('/')
def hello():
redis.incr('hits')
return 'Hello Docker Book reader! I have been seen {0} times'.format(redis.get('hits'))
if __name__ == '__main__':
app.run(host="0.0.0.0",debug=True)
[root@devops composeapp]#

③:
创建Python的依赖包描述文件

[root@devops composeapp]# touch requirements.txt
[root@devops composeapp]# vi requirements.txt
flask
redis

④:
编写Python Web容器的镜像Dockerfile文件
(这里有之前做的很详细的记录DockerFile详解 https://mp.csdn.net/mdeditor/90180708#)

[root@devops composeapp]# vi Dockerfile
FROM python2.7:test
MAINTAINER paowuxian <1300042631@qq.com>
ENV REFRESHED_AT 2019-06-23 #更新数据的时间

ADD . /composeapp

WORKDIR /composeapp

RUN pip install -r requirements.txt
# 当然这里之前我们已经手动安装好了我们所需要的依赖包描述性文件中的内容

⑤:
构建镜像
(这里说明一下我这里由于是新的系统和容器没有python2.7的镜像,那么我们就开始手动制作一个,由于篇幅有限我把制作的镜像的内容放到另外一个博客中:这是地址https://blog.csdn.net/qq_28513801/article/details/93394225)

root@devops composeapp]# docker build -t pwx/composeapp .
Sending build context to Docker daemon  4.096kB
Step 1/6 : FROM python2.7:test
---> 6121878c45f9
Step 2/6 : MAINTAINER paowuxian <1300042631@qq.com>
---> Running in 7857094abacd
Removing intermediate container 7857094abacd
---> c3fe1ff5db2c
Step 3/6 : ENV REFRESHED_AT 2019-06-23
---> Running in 6251ac1ea9e6
Removing intermediate container 6251ac1ea9e6
---> 49c008a91266
Step 4/6 : ADD . /composeapp
---> 63ca9e0f7747
Step 5/6 : WORKDIR /composeapp
---> Running in 99672539a440
Removing intermediate container 99672539a440
---> bfb74be280cc
Step 6/6 : RUN pip install -r requirements.txt
---> Running in b98fa64038db
/bin/sh: pip: command not found
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 127
[root@devops composeapp]#
这里报了一个错误,最后一行可以看到是镜像中没有pip工具 那么我们就打开我们的刚刚的打包的镜像继续添加pip工具
就在这里更新,不在重新打开刚刚的那一篇了(其实操作基本一样,只是多了两个步骤,一个是安装epel扩展
yum -y install epel-release
然后再安装python-pip 就可以了  下面我们演示一下两个过程
)
开始更新我们的镜像##########################################
[root@devops /]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
python3               test                6121878c45f9        26 minutes ago      284MB
python2.7             test                6121878c45f9        26 minutes ago      284MB
python                2.7                 693b5f09c0ee        32 minutes ago      307MB
nginx                 latest              719cd2e3ed04        12 days ago         109MB
portainer/portainer   latest              da2759008147        2 weeks ago         75.4MB
centos                latest              9f38484d220f        3 months ago        202MB
[root@devops /]# docker run -itd --name pythontest python2.7:test /bin/bash
64c3b510d902f43f9338e5cf7118a64d906302560bf6d69b0f4d80bd4d2ded63
[root@devops /]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
64c3b510d902        python2.7:test      "/bin/bash"         3 seconds ago       Up 2 seconds                            pythontest
[root@devops /]# docker exec -it 64c3b510d902  /bin/bash

首先安装epel扩展源:
[root@e64c3b510d902 /]# yum -y install epel-release

Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: ap.stykers.moe
* extras: ap.stykers.moe
* updates: ap.stykers.moe
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
Package                              Arch                           Version                      Repository                      Size
=======================================================================================================================================
Installing:
epel-release                         noarch                         7-11                         extras                          15 k

Transaction Summary
=======================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYA
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm                                                                                    |  15 kB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package    : centos-release-7-4.1708.el7.centos.x86_64 (@CentOS)
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch                                                                                            1/1
Verifying  : epel-release-7-11.noarch                                                                                            1/1

Installed:
epel-release.noarch 0:7-11

Complete!

[root@e81a1d356641 /]# yum -y install python-pip

Loaded plugins: fastestmirror, ovl
epel/x86_64/metalink                                                                                            | 5.5 kB  00:00:00
epel                                                                                                            | 5.4 kB  00:00:00
epel/x86_64/primary_db         FAILED
http://mirrors.nipa.cloud/epel/7/x86_64/repodata/d0ad247868c204570edd7b18e2137399009148f5d2e2be074165365b2ff739cf-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

(1/3): epel/x86_64/group_gz                                                                                     |  88 kB  00:00:00
epel/x86_64/updateinfo         FAILED
https://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora-projects/epel/7/x86_64/repodata/a57f1bb0ee08e200de1cd5eb45ce5c69a13ff5c049c2789cb21da90681af5ab3-updateinfo.xml.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
epel/x86_64/primary_db         FAILED
http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/repodata/d0ad247868c204570edd7b18e2137399009148f5d2e2be074165365b2ff739cf-primary.sqlite.bz2: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(2/3): epel/x86_64/updateinfo                                                                                   | 978 kB  00:00:00
epel/x86_64/primary_db         FAILED
https://mirror.ps.kz/epel/7/x86_64/repodata/d0ad247868c204570edd7b18e2137399009148f5d2e2be074165365b2ff739cf-primary.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
(3/3): epel/x86_64/primary_db                                                                                   | 6.7 MB  00:00:04
Loading mirror speeds from cached hostfile
* base: ap.stykers.moe
* epel: mirrors.nipa.cloud
* extras: ap.stykers.moe
* updates: ap.stykers.moe
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-8.el7 will be installed
--> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-8.el7.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
--> Running transaction check
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
Package                                             Arch                   Version                         Repository            Size
=======================================================================================================================================
Installing:
python2-pip                                         noarch                 8.1.2-8.el7                     epel                 1.7 M
Installing for dependencies:
python-backports                                    x86_64                 1.0-8.el7                       base                 5.8 k
python-backports-ssl_match_hostname                 noarch                 3.5.0.1-1.el7                   base                  13 k
python-ipaddress                                    noarch                 1.0.16-2.el7                    base                  34 k
python-setuptools                                   noarch                 0.9.8-7.el7                     base                 397 k

Transaction Summary
=======================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 2.1 M
Installed size: 9.4 M
Downloading packages:
(1/5): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm                                             |  13 kB  00:00:00
(2/5): python-backports-1.0-8.el7.x86_64.rpm                                                                    | 5.8 kB  00:00:00
(3/5): python-ipaddress-1.0.16-2.el7.noarch.rpm                                                                 |  34 kB  00:00:00
(4/5): python-setuptools-0.9.8-7.el7.noarch.rpm                                                                 | 397 kB  00:00:01
warning: /var/cache/yum/x86_64/7/epel/packages/python2-pip-8.1.2-8.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for python2-pip-8.1.2-8.el7.noarch.rpm is not installed
(5/5): python2-pip-8.1.2-8.el7.noarch.rpm                                                                       | 1.7 MB  00:00:02
---------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                  1.0 MB/s | 2.1 MB  00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Packa
17cd3
ge    : epel-release-7-11.noarch (@extras)
From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-backports-1.0-8.el7.x86_64                                                                                   1/5
Installing : python-ipaddress-1.0.16-2.el7.noarch                                                                                2/5
Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                                            3/5
Installing : python-setuptools-0.9.8-7.el7.noarch                                                                                4/5
Installing : python2-pip-8.1.2-8.el7.noarch                                                                                      5/5
Verifying  : python-ipaddress-1.0.16-2.el7.noarch                                                                                1/5
Verifying  : python2-pip-8.1.2-8.el7.noarch                                                                                      2/5
Verifying  : python-setuptools-0.9.8-7.el7.noarch                                                                                3/5
Verifying  : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                                            4/5
Verifying  : python-backports-1.0-8.el7.x86_64                                                                                   5/5

Installed:
python2-pip.noarch 0:8.1.2-8.el7

Dependency Installed:
python-backports.x86_64 0:1.0-8.el7                      python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7
python-ipaddress.noarch 0:1.0.16-2.el7                   python-setuptools.noarch 0:0.9.8-7.el7

Complete!

然后把我们之前的python2.7:test的镜删除掉
(docker rmi -f  <镜像名称>)
重新使用刚刚安装过pip的容器生成新的镜像python2.7:test

[root@devops ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
e81a1d356641        ff426288ea90        "/bin/bash"         13 minutes ago      Up 13 minutes                           centos7pythontest
[root@devops ~]# docker commit e81a1d356641 python2.7:test
sha256:62643ddb52f771240debdf0ffae00c46b80e86f1825463806d8531f55f3bbd4b
[root@devops ~]# docker images | grep python2.7
python2.7             test                62643ddb52f7        14 seconds ago      356MB
[root@devops ~]#

⑤ :下面开始继续构建我们的镜像:

[root@devops composeapp]# ls
app.py  Dockerfile  requirements.txt
[root@devops composeapp]# docker build  -t pwx/composeapp .
Sending build context to Docker daemon  4.096kB
Step 1/6 : FROM python2.7:test
---> 62643ddb52f7
Step 2/6 : MAINTAINER paowuxian <1300042631@qq.com>
---> Running in 69e9b82eb41c
Removing intermediate container 69e9b82eb41c
---> 9976845f9c8a
Step 3/6 : ENV REFRESHED_AT 2019-06-23
---> Running in 854c74d028a8
Removing intermediate container 854c74d028a8
---> 50220e1be1be
Step 4/6 : ADD . /composeapp
---> 6ab0478f041b
Step 5/6 : WORKDIR /composeapp
---> Running in 04c4a5335e46
Removing intermediate container 04c4a5335e46
---> 91e6de5ab134
Step 6/6 : RUN pip install -r requirements.txt
---> Running in e7f852d71a7f
Collecting flask (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/9a/74/670ae9737d14114753b8c8fdf2e8bd212a05d3b361ab15b44937dfd40985/Flask-1.0.3-py2.py3-none-any.whl (92kB)
100% |################################| 92kB 183kB/s
Collecting redis (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
100% |################################| 71kB 294kB/s
Collecting Jinja2>=2.10 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
100% |################################| 133kB 331kB/s
Collecting itsdangerous>=0.24 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Werkzeug>=0.14 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/9f/57/92a497e38161ce40606c27a86759c6b92dd34fcdb33f64171ec559257c02/Werkzeug-0.15.4-py2.py3-none-any.whl (327kB)
100% |################################| 327kB 1.7MB/s
Collecting click>=5.1 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
100% |################################| 81kB 1.5MB/s
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/fb/40/f3adb7cf24a8012813c5edb20329eb22d5d8e2a0ecf73d21d6b85865da11/MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: MarkupSafe, Jinja2, itsdangerous, Werkzeug, click, flask, redis
Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.4 click-7.0 flask-1.0.3 itsdangerous-1.1.0 redis-3.2.1
You are using pip version 8.1.2, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Removing intermediate container e7f852d71a7f
---> 55e2b8551e39
Successfully built 55e2b8551e39
Successfully tagged pwx/composeapp:latest
[root@devops composeapp]# ls

但是从最后两行建议中 我们可以看到 我们应该在我们的dockerFile文件最后再加入一条指令 ()
RUN pip install --upgrade pip

下面是修改后的DockerFile文件

[root@devops composeapp]# cat Dockerfile
FROM python2.7:test
MAINTAINER paowuxian <1300042631@qq.com>
ENV REFRESHED_AT 2019-06-23
ADD . /composeapp
WORKDIR /composeapp
RUN pip install -r requirements.txt
RUN pip install --upgrade pip

然后把刚刚构建的pwx/composeapp 的镜像给删除掉 重新构建

[root@devops composeapp]# docker build  -t pwx/composeapp .
Sending build context to Docker daemon  4.096kB
Step 1/7 : FROM python2.7:test
---> 62643ddb52f7
Step 2/7 : MAINTAINER paowuxian <1300042631@qq.com>
---> Running in dc3dbdf27b3f
Removing intermediate container dc3dbdf27b3f
---> cf4c308ce9e6
Step 3/7 : ENV REFRESHED_AT 2019-06-23
---> Running in 6d8076aa43b4
Removing intermediate container 6d8076aa43b4
---> b10d9ace4e9f
Step 4/7 : ADD . /composeapp
---> 1e3b28afdbe6
Step 5/7 : WORKDIR /composeapp
---> Running in bc51f1b3d17e
Removing intermediate container bc51f1b3d17e
---> aec44551c4ae
Step 6/7 : RUN pip install -r requirements.txt
---> Running in 0e092ad04cfd
Collecting flask (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/9a/74/670ae9737d14114753b8c8fdf2e8bd212a05d3b361ab15b44937dfd40985/Flask-1.0.3-py2.py3-none-any.whl (92kB)
100% |################################| 92kB 156kB/s
Collecting redis (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
100% |################################| 71kB 319kB/s
Collecting Jinja2>=2.10 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
100% |################################| 133kB 101kB/s
Collecting itsdangerous>=0.24 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting Werkzeug>=0.14 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/9f/57/92a497e38161ce40606c27a86759c6b92dd34fcdb33f64171ec559257c02/Werkzeug-0.15.4-py2.py3-none-any.whl (327kB)
100% |################################| 327kB 145kB/s
Collecting click>=5.1 (from flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
100% |################################| 81kB 337kB/s
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask->-r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/fb/40/f3adb7cf24a8012813c5edb20329eb22d5d8e2a0ecf73d21d6b85865da11/MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: MarkupSafe, Jinja2, itsdangerous, Werkzeug, click, flask, redis
Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.4 click-7.0 flask-1.0.3 itsdangerous-1.1.0 redis-3.2.1
You are using pip version 8.1.2, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Removing intermediate container 0e092ad04cfd
---> feb2822d30ef
Step 7/7 : RUN pip install --upgrade pip
---> Running in 59a9dd8c1f9b
Collecting pip
Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
100% |################################| 1.4MB 69kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Successfully installed pip-19.1.1
Removing intermediate container 59a9dd8c1f9b
---> 09b02cc0a156
Successfully built 09b02cc0a156
Successfully tagged pwx/composeapp:latest
[root@devops composeapp]#
上面虽然还是有提示 但是我们最后一条命令已经成功执行了

下面接着我们的顺利步骤进行

⑥ :
以Docker run 操作运行案例

[root@devops composeapp]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
pwx/composeapp        latest              09b02cc0a156        4 minutes ago       371MB
python2.7             test                62643ddb52f7        12 minutes ago      356MB
python                2.7                 693b5f09c0ee        2 hours ago         307MB
nginx                 latest              719cd2e3ed04        12 days ago         109MB
portainer/portainer   latest              da2759008147        2 weeks ago         75.4MB
centos                latest              9f38484d220f        3 months ago        202MB
centos7               test                ff426288ea90        17 months ago       207MB
[root@devops composeapp]# docker run -itd -p 5000:5000 -v.:/composeapp --link redis:redis --name pwx/composeapp:latest  python app.py
Unable to find image 'python:latest' locally
latest: Pulling from library/python
6f2f362378c5: Pull complete
494c27a8a6b8: Pull complete
7596bb83081b: Pull complete
372744b62d49: Pull complete
615db220d76c: Pull complete
39aa0c89bda1: Pull complete
ac275157d894: Pull complete
98d16dec829a: Pull complete
c8514b1c6524: Pull complete
Digest: sha256:9e0b4f32487ca1863b45383420b8db77990debae748e2e875d2f86fa9510d4a5
Status: Downloaded newer image for python:latest

⑦:
构建DockerCompose yml 文件,即docker-compose.yml文件:

web:
image:pwx/composeapp
command:python app.py
ports:
-"5000:5000"
volumes:
-.:/composeapp
links:
-redis
redis:
image:redis

这里如果执行时遇到报错问题 大概就是格式问题
这是我初次遇到的问题 并解决了
https://blog.csdn.net/qq_28513801/article/details/93405315

⑧:
切换到composeapp目录下,以compose的方式运行:

[root@devops composeapp]# docker-compose up
Pulling redis (redis:)...
latest: Pulling from library/redis
fc7181108d40: Already exists
3e0ac67cad82: Pull complete
6ee495cb7235: Pull complete
9f7206d08b9d: Pull complete
a8354ef8cccb: Pull complete
53afb10d81c2: Pull complete
Digest: sha256:ca2d9251c2818df48c6598e01a5bdeab46040dc7ab236abe075d7c7343465177
Status: Downloaded newer image for redis:latest
Creating composeapp_redis_1 ... done
Creating composeapp_web_1   ... done
Attaching to composeapp_redis_1, composeapp_web_1
redis_1  | 1:C 23 Jun 2019 12:37:59.151 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 23 Jun 2019 12:37:59.151 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 23 Jun 2019 12:37:59.151 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  | 1:M 23 Jun 2019 12:37:59.154 * Running mode=standalone, port=6379.
redis_1  | 1:M 23 Jun 2019 12:37:59.154 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 23 Jun 2019 12:37:59.154 # Server initialized
redis_1  | 1:M 23 Jun 2019 12:37:59.154 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1  | 1:M 23 Jun 2019 12:37:59.154 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1  | 1:M 23 Jun 2019 12:37:59.154 * Ready to accept connections
web_1    |  * Serving Flask app "app" (lazy loading)
web_1    |  * Environment: production
web_1    |    WARNING: This is a development server. Do not use it in a production deployment.
web_1    |    Use a production WSGI server instead.
web_1    |  * Debug mode: on
web_1    |  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
web_1    |  * Restarting with stat
web_1    |  * Debugger is active!
web_1    |  * Debugger PIN: 314-971-920

⑨:
最后在网页上访问验证效果:

历时3个小时的docker Compose 案例 终于完工,虽然其中遇到了很多问题 但是也都解决了

我觉得应该在这里进行一次总结:
多学多看多实践多总结

①:安装的时候 docker 可能不是很顺利安装 建议使用阿里云的源和加速器
https://blog.csdn.net/qq_28513801/article/details/93381492 这是docker安装方式

②:自己制作镜像的时候可能会忘记安装pip工具 那么我们上面的内容后面也进行了及时补充
docker容器中安装pip时 要注意第一步首先 epel 扩展
yum install -y epel-release

③:最重要的环节 我们要注意yml文件的书写,以及严格的格式要求
1)要注意冒号后面跟空格 否则发生报错

RROR: yaml.scanner.ScannerError: mapping values are not allowed here
in "./docker-compose.yml", line 4, column 7

2)要注意-号后面也要加空格

ERROR: The Compose file './docker-compose.yml' is invalid because:
web.volumes contains an invalid type, it should be an array
web.links contains an invalid type, it should be an array
web.ports contains an invalid type, it should be an array
---------------------
作者:抛物线.
来源:CSDN
原文:https://blog.csdn.net/qq_28513801/article/details/93405315
版权声明:本文为博主原创文章,转载请附上博文链接!

https://blog.csdn.net/qq_28513801/article/details/93405315这是今天解决的两个报错问题

基本上没有其他问题出现。
学校即将放假,接下来就有时间了
接下来 将进行DockerSwarm和Consul构建的学习

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐