Detailed process of building mongodb and mysql with docker-compose

Detailed process of building mongodb and mysql with docker-compose

Let's take a look at the detailed method of building mongodb and mysql with docker-compose. The content is as follows:

version: '3'
services:
  mysqldbservice:
    image: 'mysql:latest'
    restart: always
    container_name: mysqlcontainer
    volumes:
      - ./data:/var/lib/mysql
      - ./my.cnf:/etc/mysql/my.cnf
      - ./init:/docker-entrypoint-initdb.d/
    ports:
      - 3306:3306 #“Host port number: container port number”
    environment:
      MYSQL_ROOT_PASSWORD: ""
      MYSQL_USER: '' # Create a common user MYSQL_PASSWORD: '' # Common user password MYSQL_DATABASE: '' # Create a library mongodbservice:
  # Image name. If the version number is not specified, the latest version will be pulled by default. image: mongo:latest
    # Port mapping ports:
    # Host port: container port - 27017:27017
    # Container data mount, persistent volumes:
    # Host directory: container directory: read and write permissions - ./mongo:/data/db:rw
    - ./configdb:/data/configdb:rw
    # Set environment variables:
    - TZ=Asia/Shanghai
    #Container name container_name: mongocontainer

my.cnf

[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Custom config should go here
!includedir /etc/mysql/conf.d/

This is the end of this article about using docker-compose to build mongodb and mysql. For more information about using docker-compose to build mongodb, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker compose deploys SpringBoot project to connect to MySQL and the pitfalls encountered
  • Implementation of docker-compose deployment project based on MySQL8
  • How to run MySQL using docker-compose
  • Use dockercompose to build springboot-mysql-nginx application
  • A brief analysis of the problem of mysql being inaccessible when deployed with docker-compose
  • How to build an elk system using docker compose

<<:  How to use crontab to backup MySQL database regularly in Linux system

>>:  Page Refactoring Skills - Javascript, CSS

Recommend

HTML tag dl dt dd usage instructions

Basic structure: Copy code The code is as follows:...

This article takes you to explore NULL in MySQL

Table of contents Preface NULL in MySQL 2 NULL oc...

How to use JS code compiler Monaco

Preface My needs are syntax highlighting, functio...

HTML5+CSS3 coding standards

The Golden Rule No matter how many people are wor...

Analysis of Linux kernel scheduler source code initialization

Table of contents 1. Introduction 2. Basic Concep...

How to quickly paginate MySQL data volumes of tens of millions

Preface In backend development, in order to preve...

Implementation of Docker cross-host network (manual)

1. Introduction to Macvlan Before the emergence o...

Drop-down menu and sliding menu design examples

I found a lot of websites that use drop-down or sl...

Detailed explanation of this reference and custom properties in JavaScript

Table of contents 1. this keyword 2. Custom attri...

Centos7 installation of FFmpeg audio/video tool simple document

ffmpeg is a very powerful audio and video process...

Linux checkup, understand your Linux status (network IO, disk, CPU, memory)

Table of contents 1. Core commands 2. Common comm...

Example code for evenly distributing elements using css3 flex layout

This article mainly introduces how to evenly dist...

Using JS to determine the existence of elements in an array in ten minutes

Preface In front-end development, you often need ...