Docker container and Container cloud reading notes 1

Source: Internet
Author: User
Tags docker run haproxy

Building Docker Application Stacks

Operating system: Ubuntu 16.04.1 LTS Desktop Edition

1. Preparatory work

In exchange for NetEase source, Gedit will report a metadata alarm, ignore, sudo apt-get update, sudo apt-get upgrade after the repair

2. Install Docker and launch Docker daemon

sudo Install Apt-transport-https ca-certificatessudo apt-key adv--keyserver HKP:// p80.pool.sks-keyservers.net:80--recv-keys 58118e89f3a912897c070adbf76221572c52609d sudo apt-get updatesudoinstall docker-enginesudo service Docker start

3. Get the image required for each node in the application stack

sudo Docker pull Ubuntu sudo Docker Pull Django sudo Docker Pull Haproxy sudo  sudo docker pull Redis:3.0. 6

4. Application stack Container node start

# launch Redis containersudoDocker run-it--name Redis-master redis/bin/BashsudoDocker run-it--name redis-slave1--link redis-master:master redis/bin/BashsudoDocker run-it--name redis-slave2--link redis-master:master redis/bin/bash# start a Django containersudoDocker run-it--name APP1--link redis-master:db-v ~/projects/django/app1:/usr/src/app django/bin/BashsudoDocker run-it--name APP2--link redis-master:db-v ~/projects/django/app2:/usr/src/app django/bin/bash# starting the Haproxy containersudoDocker run-it--name HAProxy--link app1:app1--link app2:app2-p6301:6301-V ~/projects/haproxy:/tmp Haproxy/bin/bash

5. Redis Master Primary Database Container node configuration

sudo " {{ . Volumes}}"  bc8e

The error is as follows: Template parsing error:template:: 1:2: Executing "" at <. VOLUMES>: Map has no entry for key "Volumes"

It is recommended to use {{. Config.volumes}}

sudo " {{ . Config.volumes}}" bc8e
Output map[/data:{}]

grep Dafa Good

sudo grep Source
"Source": "/var/lib/docker/volumes/xxxxxxx/_data"

After the root permission is required, Ubuntu sudo CD will be error, because the CD is alias

sudo -/var/lib/docker/volumes/xxxxxxx/_datacp your Redis folder/redis.conf. Vim Redis.conf

The following parameters need to be modified

127.0. 0.1  0.0. 0.0

Switch to the container

#/var/lib/Redis This folder must be created mkdir /var/lib//dataCP redis.conf/usr/local //usr/local/binredis-server redis.conf

6. Redis slave configuration from the database Container node

Redis.conf of the modified item

6379

Same starting Mode

7. Redis Database Container node test

Master

# redis-CLI127.0. 0.1:6379> set master bc8eok127.0. 0.1:6379> get Master"bc8e"

Slave

# redis-CLI127.0. 0.1:6379> get Master"bc8e"

Info can check the current Redis status,/var/log/redis/redis.log can view the log information, if the master data is not synchronized to slave, you can use the log to assist in troubleshooting.

8. Configuration of the app container node

According to the process in the book, until the Python manage.py syncdb will report an error, because there is no such command, you need to execute a python manage.py createsuperuser

9. Configuration of the HAProxy container node

# will be an error
0.0. 0.0:6301
# You need to modify the following listen redis_proxy0.0. 0.0:6301

10. Application Stack Access test

The original book http://172.17.0.9 is a mystery address, replaced by http://127.0.0.1 or http://localhost can be broken.

Docker container and Container cloud reading notes 1

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.