Detailed explanation of software configuration using docker-compose in linux

Detailed explanation of software configuration using docker-compose in linux

Preface

This article will share some docker-compose configurations. You can refer to them to summarize your own set of docker-based development/production environment configurations. Let’s take a look at the detailed introduction.

Install docker and 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

Create a dedicated network

Use docker network to create your own dedicated common network me_gateway so that docker software can access each other

docker network create me_gateway

docker-compose deploy traefik

A reverse proxy server, it is very fast, with great features such as automatic discovery of services, automatic application for https, etc., project address, Chinese documentation.

docker-compose.yml

This is an example docker-compose.yml configuration using traefik

Among them, the mounted ./traefik.toml is its configuration.

The mounted acme.json is the configuration of 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

Detailed configuration description: http://docs.traefik.cn/toml#acme-lets-encrypt-configuration

The following is an example. If you encounter some problems when configuring verification, you can refer to the following configuration or the comments of this article

################################################################
# 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:
# To enable basic auth for an entry point
# Use 2 sets of username/password: test:test and test2:test2
# Passwords can be encrypted with MD5, SHA1 or BCrypt: You can use htpasswd to generate these usernames and passwords.
# [entryPoints]
# [entryPoints.http]
# address = ":80"
# [entryPoints.http.auth.basic]
# users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"]
#
# To enable digest auth for an entry point
# Use 2 sets of username/domain/password: test:traefik:test and test2:traefik:test2
# You can use htdigest to generate these username/domain/password [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 backend configuration#####################################################################

# Use the default domain name.
# Can be overridden by setting the "traefik.domain" label for the container.
# Enable Docker backend configuration [docker]
endpoint = "unix:///var/run/docker.sock"
domain = "yimo.link"
watch = true
exposedByDefault = false
usebindportip = true
swarmMode = false
network = "me_gateway"

[acme]
email = "[email protected]"
storage = "acme.json"
entryPoint = "https"
onDemand = false
onHostRule = true
 [acme.httpChallenge]
 entryPoint="http"

docker-compose deploys Gogs and uses traefik to bind the domain name

If you want to build with mysql, you can refer to this configuration

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

During initialization, you need to set the domain name to 0.0.0.0 or git.yimo.link

That is, the ./data/gogs/conf/app.ini item is

DOMAIN = git.yimo.link

docker-compose deploy mysql

It is worth noting that under the same network, you can directly use me_mysql to connect

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

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Docker compose configuration file writing and command usage examples
  • Using Docker Compose to build and deploy ElasticSearch configuration process
  • Docker-compose installation yml file configuration method
  • Detailed explanation of the process of deploying the distributed configuration center Apollo with one click using docker compose
  • Detailed tutorial on docker-compose deployment and configuration of Jenkins
  • How to install and configure the Docker Compose orchestration tool in Docker.v19
  • Docker-compose steps to configure the spring environment
  • Detailed explanation of Docker Compose configuration file parameters

<<:  CentOS7 uses rpm package to install mysql 5.7.18

>>:  JavaScript implements countdown on front-end web page

Recommend

MySQL5.7 single instance self-starting service configuration process

1.MySQL version [root@clq system]# mysql -v Welco...

A brief analysis of MySQL's lru linked list

1. Briefly describe the traditional LRU linked li...

Usage and best practice guide for watch in Vue3

Table of contents Preface🌟 1. API Introduction 2....

Docker+gitlab+jenkins builds automated deployment from scratch

Table of contents Preface: 1. Install Docker 2. I...

Example of converting webpack images to base64

Download url-loader yarn add -D url-loader module...

Object-Oriented Programming with XHTML and CSS

<br />If only XHTML and CSS were object-orie...

Practical record of Vue3 combined with TypeScript project development

Table of contents Overview 1. Compositon API 1. W...

Why is the disk space still occupied after deleting table data in MySQL?

Table of contents 1. Mysql data structure 2. The ...

Example code for implementing transparent gradient effects with CSS

The title images on Zhihu Discovery columns are g...

Web design must also first have a comprehensive image positioning of the website

⑴ Content determines form. First enrich the conten...

Learn the basics of JavaScript DOM operations in one article

DOM Concepts DOM: document object model: The docu...

About WeChat Mini Program to implement cloud payment

Table of contents 1. Introduction 2. Thought Anal...

Vue+webrtc (Tencent Cloud) practice of implementing live broadcast function

Table of contents 1. Live broadcast effect 2. Ste...