濮阳杆衣贸易有限公司

主頁 > 知識庫 > linux使用docker-compose部署軟件配置詳解

linux使用docker-compose部署軟件配置詳解

熱門標(biāo)簽:申請400電話價(jià)格多少 安陽ai電銷機(jī)器人軟件 涪陵商都400電話開通辦理 外呼系統(tǒng)的經(jīng)營范圍 廈門營銷外呼系統(tǒng)平臺 智能電話機(jī)器人坐席 柳州市機(jī)器人外呼系統(tǒng)報(bào)價(jià) 云會外呼系統(tǒng) 外呼系統(tǒng)不彈窗

前言

本篇將分享一些 docker-compose 的配置,可參考其總結(jié)自己的一套基于docker的開發(fā)/生產(chǎn)環(huán)境配置。下面話不多說了,來一起看看詳細(xì)的介紹吧

安裝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

創(chuàng)建專屬網(wǎng)絡(luò)

使用 docker network 創(chuàng)建自己的專屬常用網(wǎng)絡(luò) me_gateway,使得 docker 的軟件能夠互相訪問

docker network create me_gateway

docker-compose 部署 Traefik

一個反向代理服務(wù)器,它非常快,有自動發(fā)現(xiàn)服務(wù),自動申請 https 等非常棒的特性,項(xiàng)目地址,中文文檔。

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

配置詳細(xì)說明:http://docs.traefik.cn/toml#acme-lets-encrypt-configuration

以下為一個示例,在配置驗(yàn)證的時候遇到一些問題,可參考下面配置或者這篇文章的評論

################################################################
# 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:
# 要為一個入口點(diǎn)開啟基礎(chǔ)認(rèn)證(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"]
#
# 要為一個入口點(diǎn)開啟摘要認(rèn)證(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 后端配置
################################################################

# 使用默認(rèn)域名。
# 可以通過為容器設(shè)置"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 一起構(gòu)建,可參考此配置

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

初始化時需要將域名設(shè)置為 0.0.0.0 或者git.yimo.link

即 ./data/gogs/conf/app.ini 項(xiàng)為

DOMAIN = git.yimo.link

docker-compose 部署 mysql

這個值得說明的就是,同一網(wǎng)絡(luò)下,可直接使用 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

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

標(biāo)簽:蕪湖 綏化 孝感 晉城 福州 巴中 南充 撫順

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《linux使用docker-compose部署軟件配置詳解》,本文關(guān)鍵詞  linux,使用,docker-compose,部署,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《linux使用docker-compose部署軟件配置詳解》相關(guān)的同類信息!
  • 本頁收集關(guān)于linux使用docker-compose部署軟件配置詳解的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    醴陵市| 英超| 芦山县| 汤原县| 安丘市| 双桥区| 梁平县| 安义县| 沛县| 清水县| 临邑县| 乌鲁木齐市| 陵川县| 枝江市| 深泽县| 安仁县| 怀柔区| 连江县| 梁平县| 呈贡县| 互助| 定州市| 河北区| 隆化县| 中阳县| 石河子市| 南昌县| 汤原县| 清河县| 洛川县| 大英县| 休宁县| 和龙市| 汤原县| 乌什县| 资中县| 沙河市| 射洪县| 腾冲县| 铜川市| 周至县|