Docker-compose编排
# Docker-compose编排
# Wordpress
# 【题目1】容器编排
在master节点上编写/root/wordpress/docker-compose.yaml文件,具体要求如下:
(1)容器名称:wordpress;镜像:wordpress:latest;端口映射:82:80
(2)容器名称:mysql;镜像:mysql:5.6;
(3)MySQL root用户密码:123456;
(4)创建数据库wordpress。
[root@master ~]# vim /root/wordpress/docker-compose.yaml
version: '3'
services:
wordpress:
image: wordpress
ports:
- 82:80
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_PASSWORD: 123456
restart: always
mysql:
image: mysql:5.6
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: wordpress
restart: always
# Owncloud
# 【题目2】容器编排
在master节点上编写/root/owncloud/docker-compose.yaml文件,具体要求如下:
(1)容器1名称:owncloud;镜像:owncloud:latest
(2)挂载路径:/data/db/owncloud:/var/www/html/data;
(3)owncloud端口映射:5679:80;
(4)容器2名称owncloud-db;镜像:mysql:5.6;
(5)数据库密码:123456。
[root@master ~]# vim /root/owncloud/docker-compose.yaml
version: '3'
services:
owncloud:
image: owncloud
links:
- owncloud-db:owncloud-db
volumes:
- "/data/db/owncloud:/var/www/html/data"
ports:
- 5679:80
owncloud-db:
image: mysql:5.6
volumes:
- "/data/mysql/:/var/lib/mysql"
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: "123456"
# SkyWalking
# 【题目3】容器编排
在 master 节点上编写/root/docker-compose.yaml 文件(需要用到的镜像包 SkyWalking.tar 在 http 服务下),具体要求如下:
(1)容器 1 名称:elasticsearch;镜像:elasticsearch:7.8.0;端口映射:9200:9200;
(2)容器 2 名称:oap;镜像:apache/skywalking-oap-server:8.0.1-es7;端口映射: 11800:11800,12800:12800;
(3)容器 3 名称:ui;镜像:apache/skywalking-ui:8.0.1;端口映射:8082:8080。
- 编写docker-compose.yml文件
[root@master ~]# vim /data/elasticsearch/docker-compose.yaml
version: '3.3'
services:
elasticsearch:
image: elasticsearch:7.8.0
container_name: elasticsearch
ports:
- 9200:9200
environment:
discovery.type: single-node
oap:
image: apache/skywalking-oap-server:8.0.1-es7
container_name: oap
ports:
- 11800:11800
- 12800:12800
ui:
image: apache/skywalking-ui:8.0.1
container_name: ui
ports:
- 8082:8080
environment:
SW_OAP_ADDRESS: oap:12800
- 运行docker-compose并且查看状态
[root@master elasticsearch]# docker-compose up docker-compose.yaml
[root@master elasticsearch]# docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------
oap bash docker-entrypoint.sh Up 0.0.0.0:11800->11800/tcp,:::11800->11800/tcp, 1234/tcp, 0.0.0.0:12800->12800/tcp,:::12800->12800/tcp
ui bash docker-entrypoint.sh Up 0.0.0.0:8080->8080/tcp,:::8080->8080/tcp
# Rabbitmq
# 【题目4】容器编排
(1)在 master 节点上编写/root/docker-compose.yaml 文件容器名称: rabbitmq;镜像使用rabbitmq:3.8.3-management;
(2)设置rabbitmq默认用户以及密码均为root;
(3)设置容器重启策略为always;
(4)设置rabbitmq管理插件为自启动状态;
[root@master ~]# vim /root/docker-compose.yaml
version: "3.0"
services:
rabbitmq1:
container_name: rabbitmq1
image: rabbitmq:3.8.3-management
restart: always
hostname: rabbitmq1
ports:
- "4369:4369"
- "5672:5672"
- "25672:25672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: root
RABBITMQ_DEFAULT_PASS: root
RABBITMQ_ERLANG_COOKIE: CURIOAPPLICATION
# Gitlub
# 【题目5】容器编排
(1)在 master 节点上编写/root/docker-compose.yaml 文件容器名称: gitlab;镜像使用gitlab/gitlab-ce:12.9.2-ce.0;
(2)设置gitlub的主机名称为gitlab;
(3)设置容器重启策略为always;
(4)设置gitlab的端口映射为1022:22,81:80,443:443;
(5) 设置gitlab的数据卷持久化
version: "3.0"
services:
gitlab:
image: gitlab/gitlab-ce:12.9.2-ce.0
container_name: mygitlab
hostname: gitlab
ports:
- "1022:22"
- "81:80"
- "443:443"
restart: always
volumes:
- /srv/gitlab/config:/etc/gitlab
- /srv/gitlab/gitlab/logs:/var/log/gitlab
- /srv/gitlab/gitlab/data:/var/opt/gitlab
# Jenkins
# 【题目6】容器编排
(1)在 master 节点上编写/root/docker-compose.yaml 文件容器名称: jenkins;镜像使用jenkins/jenkins:2.262-centos;
(2)设置jenkins的用户默认使用root用户;
(3)设置容器重启策略为always;
(4)设置jenkins的端口映射为8080:8080;
(5) 设置jenkins的数据卷持久化,指定/var/jenkins_home
version: "3.0"
service:
jenkins:
image: jenkins/jenkins:2.262-centos
container_name: jenkins
ports:
- "8080:8080"
volumes:
- /home/jnekins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/bin/kubectl:/usr/local/bin/kubectl
- /root/.kube:/root/.kube
user: root