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/ ...
随机推荐
- APRoundedButton
APRoundedButton https://github.com/elpsk/APRoundedButton 效果: 源码: APRoundedButton.h // // Created by ...
- 乘风破浪:LeetCode真题_013_Roman to Integer
乘风破浪:LeetCode真题_013_Roman to Integer 一.前言 上一节我们讨论了如何把阿拉伯数字转换成罗马数字,现在我们需要思考一下如何把罗马数字转换成阿拉伯数字,其实我们仔细观擦 ...
- Android Proguard使用技巧
1.混淆后解码 ProGuard运行结束后,输出以下文件: dump.txt :描述.apk文件中所有类文件间的内部结构 mapping.txt:列出了原始的类,方法和字段名与混淆后代码间的映射.这个 ...
- 51nod 1349 最大值
题目看这里 找到每个元素g[i]作为最大值的区间[L,R],那么以他为最大值的区间数有(i-L+1)*(R-i+1)个. 为了加速,以k为最大值的区间数放入H[k],再以此统计一个前缀和,更新入H.那 ...
- nmap速查表v1.0(中文版)
基本语法: #nmap [扫描方式] [命令选项] {目标} 扫描目标格式: IPv4 地址: 192.168.1.1IPv6 地址:AABB:CCDD::FF%eth0主机名:www.target. ...
- C语言顺序表的实现
今天本来想写段代码练练手,想法挺好结果,栽了个大跟头,在这个错误上徘徊了4个小时才解决,现在分享出来,给大家提个醒,先贴上代码: /********************************** ...
- Jenkins在CentOS中的安装
环境准备: tomcat,jdk 包准备:Jenkins的war包,下载路径:https://jenkins.io/download/ 把下载好的war包放在tomcat的webapps中,重启tom ...
- Java的Calendar类
通过Date类我们可以创建并格式化一个日期对象,但是如何才能设置和获取日期数据的特定部分呢?----Calendar类 Calendar类是一个抽象类,在实际使用时实现特定的子类的对象,通过getIn ...
- c++ 基类,派生类的类型兼容性
#include <iostream> using namespace std; class CFather { public: void display() const { cout&l ...
- BZOJ3573:[HNOI2014]米特运输(树形DP)
Description 米特是D星球上一种非常神秘的物质,蕴含着巨大的能量.在以米特为主要能源的D星上,这种米特能源的运输和储 存一直是一个大问题.D星上有N个城市,我们将其顺序编号为1到N,1号城市 ...