Techyou labs
文章RSS
评论RSS
登录
真正的爱应该超越生命的长度,心灵的宽度,灵魂的深度
搜索
关于作者
文章分类
Default
Linux/Unix
Database
Cloud
Networking
Security
Programming
最新文章
deepin-wine6-stable下TIM悄悄崩溃问题
openwrt 设置ipv6地址分配
Redis 实战篇:巧用数据类型实现亿级数据统计
Cilium 容器网络的落地实践
Below:Facebook 开源的 Linux 系统资源监视器
How to do nat based on port number in stateless nat
LetsEncrypt根证书到期导致系统更新失败
转:Lima:Docker Desktop for Mac 的免费开源且自由的替代品
[转]Qunar 容器平台网络之道:Calico
deepin-wine-qq在ubuntu/linuxmint下常见问题
最新评论
renothing: 二次反向代理跟你应用程序得处理时间有关系吧?尤其是...
二次反向代理性能很差,怎么优化的?: 我也用nginx 做了个二次反向代理,但是并发连3...
hostyep: 交换链接么?目前每天保持30个左右对口IP,每月都...
yzhkpli: error while loading share...
美肤宝: 感谢分享。。。
lq: 嗯 喜欢弄得点单点
按月归档
March 2022
January 2022
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
February 2021
September 2020
May 2020
September 2019
August 2019
July 2019
June 2019
May 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
April 2018
March 2018
December 2017
October 2017
September 2017
August 2017
April 2017
March 2017
February 2017
August 2016
July 2015
November 2014
September 2014
August 2014
July 2014
June 2014
July 2013
April 2013
September 2012
July 2012
May 2012
April 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
June 2009
May 2009
April 2009
March 2009
February 2009
December 2008
November 2008
September 2008
August 2008
July 2008
June 2008
常用标签
Mysql
nginx
mysql优化
linux
debian
Powered by
Typecho)))
Optimized by
EAimTY
在docker-compose中使用本地目录
September 9, 2018
随着docker-compose版本3及以上版本的出现,volumes_from指令即将被移除。对于本地开发来说挂载本地目录到容器是一个很重要的需求,那么,现在你可以使用host bind方式挂载目录或定义存储卷 ``` web_app_cli: image: code4hire/dev-images:php-7.2-cli hostname: "web_app_cli" working_dir: /application volumes: - ./web-app/application:/application ``` 主机相对路径./web-app/application安装到容器/application。看起来没什么问题,但假设同一个目录要在多个容器间共享呢? ``` web_app_cli: image: code4hire/dev-images:php-7.2-cli hostname: "web_app_cli" working_dir: /application volumes: - ./web/application:/application php-fpm: image: code4hire/dev-images:php-7.2-fpm volumes: - ./web/application:/application nginx: image: nginx:latest ports: - "8080:8080" volumes: - ./web/application:/application ``` 有洁癖的人不能忍 可以通过使用环境变量替换来改进 ``` web_app_cli: image: code4hire/dev-images:php-7.2-cli hostname: "web_app_cli" working_dir: ${WEB_DESTINATION_PATH} volumes: - ${WEB_APP_PATH}:${WEB_DESTINATION_PATH} php-fpm: image: code4hire/dev-images:php-7.2-fpm volumes: - ${WEB_APP_PATH}:${WEB_DESTINATION_PATH} nginx: image: nginx:latest ports: - "8080:8080" volumes: - ${WEB_APP_PATH}:${WEB_DESTINATION_PATH} ``` 并.env在docker撰写文件所在的同一级别创建一个文件 ``` # web specific mounts and settings # Application's path (absolute or relative) # **IMPORTANT** # If you are using docker-sync, the path is relative to the location of this file # if you are NOT using docker-sync, and just docker-compose, # the path is relative to the location of docker-compose.yml WEB_APP_PATH=./web/application # Path inside of container where the application will be mounted, # This var can also be used as workdir value for docker # MAKE SURE THE VALUE IS IN SYNC WITH YOUR NGINX OR APACHE CONFIG WEB_DESTINATION_PATH=/application ``` 处理.env和docker 时需要注意的一件重要事情是Docker处理键和值的方式,即没有特殊的引号处理。这意味着它们是VAL的一部分。 最佳实践当然是在docker-compose文件里直接定义啦: ``` ... volumes: web_app: driver: local driver_opts: type: none o: bind device: $PWD/web/application ```
暂无评论
添加新评论
称呼
Email
网站
取消回复
内容
发表评论