Docker-compose multiple Docker container management: Take MySQL and WordPress for example

Source: Internet
Author: User

Move Brick Chen Master Copyright, reprint please specify: http://www.lenggirl.com/tool/docker-compose.html

Docker-compose multiple Docker container management: Take MySQL and WordPress for example

Environment: Ubuntu

[Email protected]:~$ uname-alinux jinhan-chen-110 4.4.0-83-generic #106-ubuntu SMP Mon June 17:54:43 UTC x86_64 x8 6_64 x86_64 gnu/linux[email protected]:~$ Lsb_release-ano LSB modules is available. Distributor ID:UbuntuDescription:Ubuntu 16.04.2 ltsrelease:16.04codename:xenial

Install Docker First: reference: http://www.lenggirl.com/tool/docker-ubuntu-install.html

One. Installation
Curl-l https://github.com/docker/compose/releases/download/1.8.1/docker-compose-' uname-s '-' uname-m ' >/usr/ Local/bin/docker-composechmod +x/usr/local/bin/docker-compose
Two. Pull Mirror
Docker Pull Mysqldocker Pull WordPress
Three. Edit Docker-compose.yaml
Version: ' 2 ' Services:    Web:       image:wordpress:latest      depends_on:         -db      Links:         -db      ports:         -"8002:80"      Environment:        wordpress_db_host:db:3306        wordpress_db_password:123456      volumes:        -/home/jinhan/wordpress:/var/www/html    db:       image:mysql      ports:         -"8003:3306"      Environment:         -mysql_root_password=123456      volumes:        -/home/jinhan/mysql/data:/var/lib/mysql        -/HOME/JINHAN/MYSQL/CONF:/ETC/MYSQL/CONF.D

Description

Version: ' 2 ' Services:    Web:    //Service name      image:wordpress:latest  //Mirror name      depends_on:   //Dependent service name, That is, it must be started after this service is started        -db      Links:   //link to the service, that is, for this service flood container, the network is transparent, can directly use its internal port access        -DB      ports:  // Port host mapping, on the outside can use 8002 access to the website        -"8002:80"      Environment://environment variable        wordpress_db_host:db:3306  //Database address, The service name and port, as it already links, will automatically address        wordpress_db_password:123456//Database Password      volumes:        -/home/jinhan/wordpress :/var/www/html  //Mount volume, pull image will download WordPress here, we mount it locally, so we can modify the local file    db:       image:mysql      ports:         -"8003:3306"      Environment:         -mysql_root_password=123456      volumes:        -/home/jinhan/mysql/ Data:/var/lib/mysql  //database data, hanging locally        -/home/jinhan/mysql/conf:/etc/mysql/conf.d//Database configuration, we're going to put it ourselves.

Four. Mounting volumes

We're experimenting with MySQL and WordPress.

Configure MySQL config to increase the number of connections because the number of connections can explode:

Mkdir-p/home/jinhan/mysql/confvim/home/jinhan/mysql/conf/my.cnf[mysqld]max_connections = 15000max_connect_errors = 6000open_files_limit = 65535table_open_cache = 1000skip-name-resolve

We've hung all the volumes locally so that your data will not go away every time you start!

Five. Start
Docker-compose up

Browser access: http://127.0.0.1:8002/database access: root:123456 Port 8003

If

Show variables like '%max_connect% ';

Display 15000, configuration successful!

Six. View
Docker-compose PS

Seven. Background boot
Docker-compose up-d

Eight. View logs
Docker-compose logs-f
Nine. Delete a container
Docker-compose RM
10. Ask for help
Docker-compose-h

Move Brick Chen Master Copyright, reprint please specify: http://www.lenggirl.com/tool/docker-compose.html

Docker-compose multiple Docker container management: Take MySQL and WordPress for example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.