Docker 容器编排的应用
程序员文章站
2022-06-03 14:14:08
...
案例一
提前安装好docker-compose
使用 mysql:5.6 镜像和 WordPress:latest镜像,在/root/wordpress目录下创建docker-compose.yaml文件,编排部署WordPress,并设置restart策略
[aaa@qq.com ~]# mkdir wordpress
[aaa@qq.com ~]# cd wordpress/
[aaa@qq.com wordpress]# vi docker-compose.yaml
注意每一行的缩进
mysql:
image: mysql:5.6
restart: always
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: 123456
wordpress:
image: wordpress:latest
restart: always
ports:
- "80:80"
links:
- "mysql:mysql"
environment:
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: 123456
启动测试
[aaa@qq.com wordpress]# docker-compose up -d
Creating wordpress_mysql_1 ... done
Creating wordpress_wordpress_1 ... done
查看启动是否成功
[aaa@qq.com wordpress]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f521eb4ab925 wordpress:latest "docker-entrypoint..." 22 seconds ago Up 20 seconds 0.0.0.0:80->80/tcp wordpress_wordpress_1
1ab669a6cb05 mysql:5.6 "docker-entrypoint..." 26 seconds ago Up 22 seconds 0.0.0.0:3306->3306/tcp wordpress_mysql_1
浏览器登录访问
案例二
使用 mysql:5.6 镜像和 owncloud :latest镜像,在/root/owncloud目录下创建docker-compose.yaml文件,编排部署owncloud,并设置restart策略
[aaa@qq.com ~]# mkdir owncloud
[aaa@qq.com ~]# cd owncloud/
[aaa@qq.com owncloud]# vi docker-compose.yaml
mysql:
image: mysql:5.6
restart: always
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: owncloud
MYSQL_USER: owncloud
MYSQL_PASSWORD: 123456
owncloud:
image: owncloud:latest
restart: always
ports:
- "80:80"
links:
- "mysql:mysql"
environment:
WONCLOUD_DB_NAME: owncloud
WONCLOUD_DB_USER: owncloud
WONCLOUD_DB_PASSWORD: 123456
启动测试
[aaa@qq.com owncloud]# docker-compose up -d
Creating owncloud_mysql_1 ... done
Creating owncloud_owncloud_1 ... done
查看启动状态
[aaa@qq.com owncloud]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5877ec11c807 owncloud:latest "docker-entrypoint..." 29 seconds ago Up 27 seconds 0.0.0.0:80->80/tcp owncloud_owncloud_1
db8a0d1e7645 mysql:5.6 "docker-entrypoint..." 30 seconds ago Up 29 seconds 0.0.0.0:3306->3306/tcp owncloud_mysql_1
浏览器访问测试
上一篇: Windows下安装使用Sphinx
推荐阅读
-
docker overlay实现跨主机的容器互通的方法
-
Redis快速部署为Docker容器的实现方法
-
Docker如何使用link建立容器之间的连接
-
在Docker上用Nacos1.3容器连接MySQL5.6和8.0.18容器进入持久化的具体操作(Nacos单机版)
-
不同物理机中的Docker容器互连(Openvswitch)
-
Docker容器安装的mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'
-
Docker配置本地镜像与容器的存储位置
-
Spring Boot应用发布到Docker的实现
-
SpringBoot应用部署于外置Tomcat容器的方法
-
使用Docker来加速构建Android应用的基本部署思路解析