Linux4

python开发案例集锦
Docker compose
[root@iz2ze7pyqb098vwyxxnq3wz /]# docker-compose --version

from flask import Flask
from redis import Redis

app = Flask(name)
redis = Redis(host=‘redis’, port=6379)

@app.route(’/’)
def hello():
count = redis.incr(‘hits’)
return ‘Hello World! 该页面已被访问 {} 次。\n’.format(count)

if name == “main”:
app.run(host=“0.0.0.0”, debug=True)

[root@iz2ze7pyqb098vwyxxnq3wz home]# mkdir compose1
[root@iz2ze7pyqb098vwyxxnq3wz home]# cd compose1/
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# ls
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# vim app.py

[root@iz2ze7pyqb098vwyxxnq3wz compose1]# ls
app.py
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# vim app.py
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# vim Dockerfile
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# vim docker-compose.yml
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# vim docker-compose.yml
[root@iz2ze7pyqb098vwyxxnq3wz compose1]# docker-compose up

[root@iz2ze7pyqb098vwyxxnq3wz home]# rz
[root@iz2ze7pyqb098vwyxxnq3wz home]# ls
1.txt compose2.zip df3 hupu.zip rabbitmq.tar
admin df1 df4 installDocker.zip setuptools-19.6
compose1 df2 hupu python37 setuptools-19.6.tar.gz
[root@iz2ze7pyqb098vwyxxnq3wz home]# unzip compose2.zip
Archive: compose2.zip
creating: compose2/
inflating: compose2/:
inflating: compose2/Dockerfile
inflating: compose2/app.py
inflating: compose2/docker-compose.yml
[root@iz2ze7pyqb098vwyxxnq3wz home]# diff compose1/app.py compose2/app.py

YAML

nginx


build: ./app = docker build -t 镜像 ./app

pip freeze > requirements.txt

  • ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro 只读

privileged: true 给容器root权限

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值