linux使用docker-compose部署软件配置
本篇将分享一些 docker-compose 的配置,可参考其总结自己的一套基于docker的开发/生产环境配置。下面话不多说了,来一起看看详细的介绍吧
安装docker及docker-compose
install docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
install docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
创建专属网络
使用 docker network 创建自己的专属常用网络 me_gateway,使得 docker 的软件能够互相访问
docker network create me_gateway
docker-compose 部署 Traefik
docker-compose.yml
这是一个使用 traefik 的 docker-compose.yml 配置示例
其中,挂载的 ./traefik.toml 为其配置,
挂载的 acme.json 为 Let's Encrypt 的配置
version: '3'
version: '3' services:
me_traefik:
image: traefik:1.7.4
container_name: me_traefik
ports:
- '80:80'
- '443:443'
- '8090:8090'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.toml:/traefik.toml
- ./acme.json:/acme.json
networks:
- webgateway
networks:
webgateway:
external:
name: me_gateway
traefik.toml
配置详细说明:http://docs.traefik.cn/toml#acme-lets-encrypt-configuration
以下为一个示例,在配置验证的时候遇到一些问题,可参考下面配置或者这篇文章的评论
################################################################
# Global configuration
################################################################ # Enable debug mode
#
# Optional
# Default: false
#
debug = false # Log level
#
# Optional
# Default: "ERROR"
#
logLevel = "ERROR" # Entrypoints to be used by frontends that do not specify any entrypoint.
# Each frontend can specify its own entrypoints.
#
# Optional
# Default: ["http"]
#
defaultEntryPoints = ["http","https"]
################################################################
# Entrypoints configuration
################################################################ # Entrypoints definition
#
# Optional
# Default:
# 要为一个入口点开启基础认证(basic auth)
# 使用2组用户名/密码: test:test 与 test2:test2
# 密码可以以MD5、SHA1或BCrypt方式加密:你可以使用htpasswd来生成这些用户名密码。
# [entryPoints]
# [entryPoints.http]
# address = ":80"
# [entryPoints.http.auth.basic]
# users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
#
# 要为一个入口点开启摘要认证(digest auth)
# 使用2组用户名/域/密码: test:traefik:test 与 test2:traefik:test2
# 你可以使用htdigest来生成这些用户名/域/密码
[entryPoints]
[entryPoints.http]
address = ":80"
# [entryPoints.http.redirect]
# entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[entryPoints.webentry]
address = ":8090"
[entryPoints.webentry.auth]
[entryPoints.webentry.auth.basic]
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"]
################################################################
# API and dashboard configuration
################################################################ # Enable API and dashboard
[api]
dashboard = true
entrypoint = "webentry" ################################################################
# Ping configuration
################################################################ # Enable ping
[ping] # Name of the related entry point
#
# Optional
# Default: "traefik"
#
# entryPoint = "traefik" ################################################################
# Docker 后端配置
################################################################ # 使用默认域名。
# 可以通过为容器设置"traefik.domain" label来覆盖。
# 启用Docker后端配置
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "yimo.link"
watch = true
exposedByDefault = false
usebindportip = true
swarmMode = false
network = "me_gateway" [acme]
email = "yimo666666@qq.com"
storage = "acme.json"
entryPoint = "https"
onDemand = false
onHostRule = true
[acme.httpChallenge]
entryPoint="http"
docker-compose 部署 Gogs,并使用 traefik 绑定域名
如果想要与 mysql 一起构建,可参考此配置
docker-compose.yml
version: '3'
services:
me_gogs:
restart: always
image: gogs/gogs
container_name: me_gogs
volumes:
- ./data:/data
- ./logs:/app/gogs/log
ports:
- '10022:22'
- '10080:3000'
labels:
- 'traefik.backend=me_gogs'
- 'traefik.frontend.rule=Host:git.yimo.link'
- 'traefik.enable=true'
- 'traefik.protocol=http'
- 'traefik.port=3000'
networks:
- webgateway
networks:
webgateway:
external:
name: me_gateway
初始化时需要将域名设置为 0.0.0.0 或者git.yimo.link
即 ./data/gogs/conf/app.ini 项为
DOMAIN = git.yimo.link
docker-compose 部署 mysql
这个值得说明的就是,同一网络下,可直接使用 me_mysql 连接
docker-compose.yml
version: '3'
services:
me_mysql:
image: mysql:5.7.21
container_name: me_mysql
volumes:
- ./data:/var/lib/mysql
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=root
networks:
- webgateway
networks:
webgateway:
external:
name: me_gateway
您可能感兴趣的文章:
- docker-compose 详解及示例代码
- Docker-compose的安装和设定详细步骤
- Docker-Compose的使用示例详解
- Ubuntu15.10安装docker和docker-compose教程
- 利用docker-compose搭建AspNetCore开发环境
- 浅谈docker-compose网络设置之networks
- 详解Docker-compose networks 的例子
- 浅析docker-compose部署mysql无法访问的问题
- 详解通过docker和docker-compose实现eureka高可用
- Docker-compose部署gitlab的方法步骤
文章同步发布: https://www.geek-share.com/detail/2755962483.html
linux使用docker-compose部署软件配置的更多相关文章
- Docker Compose 部署 Redis 及原理讲解 | 懒人屋
原文:Docker Compose 部署 Redis 及原理讲解 | 懒人屋 Docker Compose 部署 Redis 及原理讲解 4.4k 字 16 分钟 2019-10-1 ...
- 使用Docker Compose部署基于Sentinel的高可用Redis集群
使用Docker Compose部署基于Sentinel的高可用Redis集群 https://yq.aliyun.com/articles/57953 Docker系列之(五):使用Docker C ...
- Docker Compose 部署前后端分离应用
部署前后端分离应用 容器化 Abp 应用 关于 Abp 应用的容器化,其实和普通的 ASP.NET Core 应用差不多,大家可以参考我此前的文章. 唯一需要注意的是:因为 Abp 解决方案中有多个项 ...
- Docker Compose部署项目到容器-基于Tomcat和mysql的项目yml配置文件代码
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- 在Windows Server 2019通过Docker Compose部署Asp.Net Core
一.安装Docker Enterprise 安装文档是: https://docs.docker.com/install/windows/docker-ee/ 安装完成后,如下图 二.首先,拉取一个W ...
- 使用Docker Compose 部署Nexus后初次登录账号密码不正确,并且在nexus-data下没有admin,password
场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/ ...
- Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程)
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- Docker Compose部署Nexus3时的docker-compose,yml代码
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- Docker Compose部署GitLab服务,搭建自己的代码托管平台(图文教程)
场景 Docker-Compose简介与Ubuntu Server 上安装Compose: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...
- 使用Docker Compose 部署Nexus后提示:Unable to create directory /nexus-data/instance
场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/ ...
随机推荐
- [翻译] BBCyclingLabel
BBCyclingLabel BBCyclingLabel is just like a UILabel but allows you to perform custom animations whe ...
- 什么是TTL值?(简单明了的解释)
什么是TTL值? TTL值全称是“生存时间(Time To Live)”,简单的说它表示DNS记录在DNS服务器上的缓存时间. 要理解TTL值,请先看下面的一个例子:假设,有这样一个域名myhost. ...
- Python中readline()函数 去除换行符
从Python中readline()函数读取的一行内容中含有换行符\n,很多时候我们需要处理不含有换行符的字符串,此时就要去掉换行符\n. 方法是使用strip()函数. 例子如下: f = open ...
- Angular2 Pipe
AngularJs 1.x 中使用filters来帮助我们转换templates中的输出,但在Angular2中使用的是pipes,以下展示Angular 1.x and Angular 2中filt ...
- 一款不错的网站压力测试工具webbench
webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统:Linux 2.编译安装: 引用 wget htt ...
- SpringMVC DELETE,PUT请求报错 添加支持Http的DELETE、PUT请求
SpringMVC删除与修改操作需要用DELETE,PUT请求方式提交. 但要知道浏览器form表单只支持GET与POST请求,而DELETE.PUT等method并不支持. spring3.0添加了 ...
- 聚类之高斯混合模型(Gaussian Mixture Model)【转】
k-means应该是原来级别的聚类方法了,这整理下一个使用后验概率准确评测其精度的方法—高斯混合模型. 我们谈到了用 k-means 进行聚类的方法,这次我们来说一下另一个很流行的算法:Gaussia ...
- C#简单实现LRU缓存
最近跟同学吃饭扯淡的时候,由技术扯到薪资,又由薪资扯到他找工作时跟面试官是怎么扯淡拿高工资的,各种技术一顿侃,总之只要啥都了解就没问题了.谈到缓存的时候,我试探性的问了问- -你还记得LRU怎么写吗, ...
- mysql 全量备份与增量备份
全量备份[root@master adm]# cat DBfullBak.sh #!/bin/bash #use mysqldump to fully backup mysql data BakDir ...
- Mysql实现主从同步
根据网上众多参考案例,继续在VM虚拟机里实现MySQL主从同步功能.步骤如下: * 首先明确下环境 主库本地windows ip192.168.0.103 从库虚拟机mysql5.6 ip192.16 ...