Docker-compose介绍
docker-compose(单机版的容器编排工具)
ansible剧本1 2 3 | yum install -y python 2 -pip(需要epel源) pip install docker-compose(默认pypi源在国外) 这条命令不执行,执行下面的命令,加过速的 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose 临时加速 |
##pip 加速
##详细指令
http://www.jianshu.com/p/2217cfed29d7
http://www.jianshu.com/p/2217cfed29d7
在这里创建一个目录,写好docker-compose配置文件,注意一定是docker-compose.yml文件名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | cd my_wordpress/ vi docker-compose.yml version: '3' services: db: image: mysql: 5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest volumes: - web_data:/var/www/html ports: - "80:80" restart: always environment: WORDPRESS_DB_HOST: db: 3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress volumes: db_data: web_data: |
#启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | docker-compose up ..................................... ys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. db_ 1 | 2019 -07 -06 T 13: 00: 43.376082 Z 0 [Note] Event Scheduler: Loaded 0 events db_ 1 | 2019 -07 -06 T 13: 00: 43.376296 Z 0 [Note] mysqld: ready for connections. db_ 1 | Version: '5.7.15' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) wordpress_ 1 | WordPress not found in /var/www/html - copying now... wordpress_ 1 | Complete! WordPress has been successfully copied to /var/www/html wordpress_ 1 | AH 00558: apache 2: Could not reliably determine the server 's fully qualified domain name, using 172.19.0.3. Set the ' ServerName' directive globally to suppress this message wordpress_ 1 | AH 00558: apache 2: Could not reliably determine the server 's fully qualified domain name, using 172.19.0.3. Set the ' ServerName' directive globally to suppress this message wordpress_ 1 | [Sat Jul 06 13: 00: 46.643865 2019 ] [mpm_prefork:notice] [pid 1 ] AH 00163: Apache/ 2.4 . 25 (Debian) PHP/ 7.3 . 6 configured -- resuming normal operations wordpress_ 1 | [Sat Jul 06 13: 00: 46.643951 2019 ] [core:notice] [pid 1 ] AH 00094: Command line: 'apache2 -D FOREGROUND' 在这里就夯住了,这是正确的,容易需要夯住才能运行 这里和docker logs 容器ID 去查看日志是一样的 |
这里使用的是debian的系统,用的是apache作为web,可以页面测试:

#后台启动
1 2 3 | [root@docker 1 web]# docker-compose up -d Starting web_db_ 1 ... done Starting web_wordpress_ 1 ... done |
关闭的命令是down
1 2 3 4 5 6 | [root@docker 1 web]# docker-compose down Stopping web_wordpress_ 1 ... done Stopping web_db_ 1 ... done Removing web_wordpress_ 1 ... done Removing web_db_ 1 ... done Removing network web_defaul |
更多内容关注https://docs.docker.com官网介绍...................
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步