Moon Light Box

Time is Money

Posts match “ docker ” tag:

Linux - Install Docker in CentOS7

| Comments

1. This method will install Docker 1.10.3 version.

# yum update

# yum install docker

# systemctl start docker

# systemctl enable docker

2. If you want to install the latest offical version (1.12.1).

# tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

# yum update

# yum install docker-engine

# systemctl start docker

# systemctl enable docker

https://wiki.centos.org/zh-tw/Cloud/Docker
https://docs.docker.com/engine/installation/linux/centos/

Docker - Install MariaDB and phpMyAdmin

| Comments

I use private registry (10.10.10.10:5566).

# docker run --name dbdata 10.10.10.10:5566/mariadb echo "this is volume container"
# docker run --name mariadb -e MYSQL_ROOT_PASSWORD=1q2w3e4r --volumes-from dbdata -d 10.10.10.10:5566/mariadb
# docker run --name myadmin -d --link mariadb:db -p 8080:80 10.10.10.10:5566/phpmyadmin/phpmyadmin

Open browser http://127.0.0.1:8080 then enter root/1q2w3e4r. Enjoy it.

https://chnbohwr.myds.me/wordpress/?p=380

Docker - Insecure Registry

| Comments

Use CentOS7.

Docker 1.10.3

# vim /etc/sysconfig/docker

Uncomment this line.
INSECURE_REGISTRY='--insecure-registry 192.168.1.1:5566 --insecure-registry 192.168.1.2:5566'

# systemctl start docker

Docker 1.12+ use JSON format

# vim /etc/docker/daemon.json

Add this line.
{ "insecure-registries":["192.168.1.1:5566", "192.168.1.2:5566"] }

# systemctl restart docker

Docker Login

# docker login -u ACCOUNT 192.168.1.1:5566
# docker login -u ACCOUNT 192.168.1.2:5566

http://www.jianshu.com/p/8f90b4a457d4

Docker - MQTT VerneMQ Cluster

| Comments

Prepare three nodes.

Node1:10.10.10.10
# docker run \
    --name vernemq \
    --net=host \
    -e "DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on" \
    -e "DOCKER_VERNEMQ_ALLOW_MULTIPLE_SESSIONS=on" \
    -d erlio/docker-vernemq
Node2:10.10.10.11
Node3:10.10.10.12
# docker run \
    --name vernemq \
    --net=host \
    -e "DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on" \
    -e "DOCKER_VERNEMQ_ALLOW_MULTIPLE_SESSIONS=on" \
    -e "DOCKER_VERNEMQ_DISCOVERY_NODE=10.10.10.10" \
    -d erlio/docker-vernemq

Check Cluster Status

Node1:10.10.10.10
# docker exec -it vernemq bash
root@vernemq01:/# vmq-admin cluster status
+---------------------+-------+
|        Node         |Running|
+---------------------+-------+
|VerneMQ@10.10.10.10  | true  |
|VerneMQ@10.10.10.11  | true  |
|VerneMQ@10.10.10.12  | true  |
+---------------------+-------+

http://www.ntex.tw/wordpress/2848.html
https://github.com/erlio/docker-vernemq
https://vernemq.com/blog/2016/08/26/loadtesting-mqtt-brokers.html
http://www.ntex.tw/wordpress/2842.html

Docker - MariaDB Galera Cluster

| Comments

node1, node2, node3

[mysqld]
character-set-server=utf8mb4
collation_server=utf8mb4_unicode_ci

[server]
bind-address=0.0.0.0
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1
query_cache_size=0
query_cache_type=0

[galera]
wsrep_on=ON
wsrep_provider="/usr/lib/galera/libgalera_smm.so"
wsrep_cluster_address="gcomm://10.10.10.10,10.10.10.11,10.10.10.12"
wsrep-sst-method=rsync

# Optional setting
wsrep_slave_threads=8
#innodb_flush_log_at_trx_commit=0
docker run -d \
--name mariadb \
--net=host \
-v /YOUR_MYSQL_DB_PATH/mysql.conf.d:/etc/mysql/conf.d \
-v /YOUR_MYSQL_DB_PATH/mysql:/var/lib/mysql \
-e MYSQL_INITDB_SKIP_TZINFO=yes \
-e MYSQL_ROOT_PASSWORD=YOUR_PASSWORD \
mariadb:10.3.0 \
--wsrep-new-cluster \
--wsrep_node_address=10.10.10.10

docker run -d \
--name mariadb \
--net=host \
-v /YOUR_MYSQL_DB_PATH/mysql.conf.d:/etc/mysql/conf.d \
-v /YOUR_MYSQL_DB_PATH/mysql:/var/lib/mysql \
-e MYSQL_INITDB_SKIP_TZINFO=yes \
-e MYSQL_ROOT_PASSWORD=YOUR_PASSWORD \
mariadb:10.3.0 \
--wsrep_node_address=10.10.10.11

docker run -d \
--name mariadb \
--net=host \
-v /YOUR_MYSQL_DB_PATH/mysql.conf.d:/etc/mysql/conf.d \
-v /YOUR_MYSQL_DB_PATH/mysql:/var/lib/mysql \
-e MYSQL_INITDB_SKIP_TZINFO=yes \
-e MYSQL_ROOT_PASSWORD=YOUR_PASSWORD \
mariadb:10.3.0 \
--wsrep_node_address=10.10.10.12

docker exec -it mariadb bash

mysql -u root -p

SHOW STATUS LIKE 'wsrep_%';

CREATE USER 'YOUR_ACCOUNT'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD';

GRANT ALL PRIVILEGES ON *.* TO 'YOUR_ACCOUNT'@'localhost' WITH GRANT OPTION;

CREATE USER 'YOUR_ACCOUNT'@'%' IDENTIFIED BY 'YOUR_PASSWORD';

GRANT ALL PRIVILEGES ON *.* TO 'YOUR_ACCOUNT'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

http://benjr.tw/95536
http://blog.yam.com/keynes0918/article/63269343
http://www.pupuliao.info/2016/05/mariadbgalera-%E7%9A%84%E3%84%A7%E4%BA%9B%E5%84%AA%E7%BC%BA%E9%BB%9E/
http://livinote.com/post/MariaDB-Galera-Cluster%E6%9E%B6%E8%A8%AD
https://severalnines.com/blog/how-bootstrap-mysqlmariadb-galera-cluster

Docker - HAProxy

| Comments

# docker run -d --name haproxy -v /opt/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro -p 3306:3306 -p 9000:9000 -p 1883:1883 -p 8888:8888 haproxy:1.6.9

Docker - RabbitMQ Cluster

| Comments

Prepare three nodes.

Node1:10.10.10.10 hostname:rabbitmq01
Node2:10.10.10.11 hostname:rabbitmq02
Node3:10.10.10.12 hostname:rabbitmq03

# docker run -d \
    --hostname rabbitmq01 or rabbitmq02 or rabbitmq03
    --name rabbitmq \
    -e RABBITMQ_ERLANG_COOKIE=2a91315f0f02f94005d94ee5d450cc86 \ // Example:2a91315f0f02f94005d94ee5d450cc86
    -e RABBITMQ_DEFAULT_USER=admin \
    -e RABBITMQ_DEFAULT_PASS=admin \
    -e RABBITMQ_HIPE_COMPILE=1 \
    -p 4369:4369 \
    -p 5672:5672 \
    -p 15672:15672 \
    -p 25672:25672 \
    --add-host rabbitmq01:10.10.10.10 \
    --add-host rabbitmq02:10.10.10.11 \
    --add-host rabbitmq03:10.10.10.12 \
    rabbitmq:3.6.6-management

Add Node2 and Node3 into cluster with Node1.

Node1:10.10.10.10 hostname:rabbitmq01
Node2:10.10.10.11 hostname:rabbitmq02
Node3:10.10.10.12 hostname:rabbitmq03

We need do this in Node2 and Node3, respectively.

# docker exec rabbitmq rabbitmqctl stop_app
# docker exec rabbitmq rabbitmqctl join_cluster rabbit@rabbitmq01
# docker exec rabbitmq rabbitmqctl start_app

Sync all nodes.

Node1:10.10.10.10 hostname:rabbitmq01
Node2:10.10.10.11 hostname:rabbitmq02
Node3:10.10.10.12 hostname:rabbitmq03

We need do this in Node1.

# docker exec rabbitmq rabbitmqctl set_policy ha-all '^(?!amq\.).*' '{"ha-mode": "all"}'
...
...
Setting policy "ha-all" for pattern "^(?!amq\\.).*" to "{\"ha-mode\": \"all\"}" with priority "0" ...

Check status.
# docker exec rabbitmq rabbitmqctl list_policies
...
...
Listing policies ...
/       ha-all  all     ^(?!amq\\.).*   {"ha-mode":"all"}       0

# docker exec -ti rabbitmq rabbitmqctl cluster_status
Cluster status of node rabbit@rabbitmq01 ...
[{nodes,[{disc,[rabbit@rabbitmq01,rabbit@rabbitmq02,rabbit@rabbitmq03]}]},
 {running_nodes,[rabbit@rabbitmq02,rabbit@rabbitmq03,rabbit@rabbitmq01]},
 {cluster_name,<<"rabbit@rabbitmq01">>},
 {partitions,[]},
 {alarms,[{rabbit@rabbitmq02,[nodedown]},
          {rabbit@rabbitmq03,[nodedown]},
          {rabbit@rabbitmq01,[]}]}]

RabbitMQ Web Console

http://10.10.10.10:15672
Enter admin / admin

http://allexit.blogspot.tw/2016/03/rabbitmq-docker-cluster.html
https://godleon.github.io/blog/2015/06/02/Build-RabbitMQ-Cluster-in-Ubuntu
http://www.rabbitmq.com/clustering.html#auto-config
https://hub.docker.com/_/rabbitmq/

Docker - Install Keycloak

| Comments

# docker run -d --name keycloak -p 8080:8080 -e PROXY_ADDRESS_FORWARDING=true -e KEYCLOAK_USER=johnny -e KEYCLOAK_PASSWORD=1q2w3e4r --restart unless-stopped jboss/keycloak

If you enconter this error.

{{notification.header}} {{notification.message}} 
Loading... 

Add below headers in nginx config of keycloak.

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

http://piotrnowicki.com/java/2017/01/09/keycloak-docker-with-ssl-proxy/

http://www.codingpedia.org/ama/how-to-configure-nginx-in-production-to-serve-angular-app-and-reverse-proxy-nodejs#nginx-configuration-to-reverse-proxy-keycloak