关于docker-compose的学习

2018年11月18日12:54:44 发表评论浏览:61

序:工欲善其事,必先利其器,centos7 python 有的pip都没有。。。。

yum -y install epel-release
yum -y install python-pip
pip install --upgrade pip
pip install docker-compose

在网上找了很多篇教程,看的还是半懂不懂,还是直接看视频比较快,但是视频只能帮助理解。最终还是要靠文字。

对了docker 运行容器以下形式时

docker run --name test001 -idt java:8u111-jdk

docker-compose配置需要加上tty:true

master: image: java:8u111-jdk tty: true

然后docker-compose up 才能够启动

我看的视频是B站av号:av24143098,据搬运大神说的油管地址

https://www.youtube.com/watch?v=q5J3rtAGGNU

脚步直接复制可能无法使用,需要格式调节,我这只是记录下

视频第一部分:docker-compose.yaml
version:'3'

services: mysql-dev: image:mysql:8.0.12 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:blogapp ports: -"3308:3306"

docker-compose updocker-compose ps

用客户端工具调试

视频第二部分:docker-compose.yaml
version:'3'

services: mysql-dev: image:mysql:8.0.12 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:blogapp ports: -"3308:3306" client: image:mysql:8.0.12 depends_on: - mysql-dev command: mysql -uroot -ppassword -hmysql-dev blogapp

说明:-hmysql-dev 和mysql-dev 一致

docker-compose run -rm client

docker-compose exec mysql-dev mysql -uroot -ppassword blogapp

第三部分:加入老的myslq:docker-compose.yaml
version:'3'

services: mysql-dev: image:mysql:8.0.12 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:blogapp ports: -"3308:3306"

myslq_legacty: image:mysql:5.7 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:legactyapp ports: -"3309:3306"

#client:# image:mysql:8.0.12# depends_on:# - mysql-dev# command: mysql -uroot -ppassword -hmysql-dev blogapp <br></pre><p>用客户端工具连接调试<br></p><h5>第四部分添加my.conf配置文件</h5><p>my.conf配置文件</p><pre>[mysqld]

bind-address = 0.0.0.0 max_connections = 505 max_user_connections = 500

docker-compose.yaml

version:'3'

services: mysql-dev: image:mysql:8.0.12 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:blogapp ports: -"3308:3306" volumes: -"./my.conf:/etc/mysql/conf.d/config-file.conf"

myslq_legacty: image:mysql:5.7 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:legactyapp ports: -"3309:3306"

#client:# image:mysql:8.0.12# depends_on:# - mysql-dev# command: mysql -uroot -ppassword -hmysql-dev blogapp<br></pre><h5>第五部分:添加data文件,docker-compose.yaml</h5><pre>version:'3'

services: mysql-dev: image:mysql:8.0.12 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:blogapp ports: -"3308:3306" volumes: -"./my.conf:/etc/mysql/conf.d/config-file.conf" -"./data:/var/lib/mysql:rw"

myslq_legacty: image:mysql:5.7 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:legactyapp ports: -"3309:3306"

#client:# image:mysql:8.0.12# depends_on:# - mysql-dev# command: mysql -uroot -ppassword -hmysql-dev blogapp<br></pre><h5>第六部分:添加adminer管理工具及pgsql,docker-compose.yaml</h5><pre>version:'3'

services: mysql-dev: image:mysql:8.0.12 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:blogapp ports: -"3308:3306" volumes: -"./my.conf:/etc/mysql/conf.d/config-file.conf" -"./data:/var/lib/mysql:rw"

myslq_legacty: image:mysql:5.7 enviroment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE:legactyapp ports: -"3309:3306"

pgdb: image:postgres enviroment: POSTGRES_USER:root POSTGRES_PASSWORD:password POSTGRES_DB:blogapp admin: image:adminer ports: - 8080:8080

#client:

image:mysql:8.0.12

depends_on:

- mysql-dev

command: mysql -uroot -ppassword -hmysql-dev blogapp

docker-compose exec pgdb pgsql -U root -W blogapp

好了,大致是这样。对了,还有下面那个地址很重要

https://store.docker.com/images/mysql

 

原文链接:https://www.datayang.com/article/38

  • 微信(WeChat)
  • 多少不重要
  • weinxin
  • 支付宝(Alipay)
  • 有鼓励就好
  • weinxin
voice 站点
资生堂 洗颜专科洗面奶
日本Sato佐藤 新生儿无激素护臀膏 30g
澳大利亚Lucas Papaw Ointment神奇番木瓜膏 25g
进口洗发水一件代发,微商货源,韩国RYOE吕 洗发两支装 红吕

发表评论

:?::razz::sad::evil::!::smile::oops::grin::eek::shock::???::cool::lol::mad::twisted::roll::wink::idea::arrow::neutral::cry::mrgreen: