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

Detailed explanation of the role of the new operator in Js

Preface Js is the most commonly used code manipul...

How to change the MySQL database file directory in Ubuntu

Preface The company's Ubuntu server places th...

MySQL 5.7.15 version installation and configuration method graphic tutorial

This article shares with you a detailed tutorial ...

Docker installation rocketMQ tutorial (most detailed)

RocketMQ is a distributed, queue-based messaging ...

Summary of Linux vi command knowledge points and usage

Detailed explanation of Linux vi command The vi e...

SQL Aggregation, Grouping, and Sorting

Table of contents 1. Aggregate Query 1. COUNT fun...

A brief discussion on Linux virtual memory

Table of contents origin Virtual Memory Paging an...

Implementation of nested jump of vue routing view router-view

Table of contents 1. Modify the app.vue page 2. C...

How to write HTML head in mobile device web development

Copy code The code is as follows: <head> &l...

How to implement the @person function through Vue

This article uses vue, and adds mouse click event...

Use of Linux tr command

1. Introduction tr is used to convert or delete a...

Solution to forgetting MySQL root password in MACOS

MySQL is a relational database management system ...

Vue+echarts realizes progress bar histogram

This article shares the specific code of vue+echa...