Docker-compose介紹

 

 

docker-compose(單機版的容器編排工具)
ansible劇本
yum install -y python2-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
在這裏建立一個目錄,寫好docker-compose配置文件,注意必定是docker-compose.yml文件名
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:
#啓動
docker-compose up
.....................................
ys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1         | 2019-07-06T13:00:43.376082Z 0 [Note] Event Scheduler: Loaded 0 events
db_1         | 2019-07-06T13:00:43.376296Z 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  | AH00558: apache2: 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  | AH00558: apache2: 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] AH00163: 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] AH00094: Command line: 'apache2 -D FOREGROUND'    在這裏就夯住了,這是正確的,容易須要夯住才能運行


這裏和docker logs 容器ID 去查看日誌是同樣的

  

這裏使用的是debian的系統,用的是apache做爲web,能夠頁面測試:

 

 

#後臺啓動
[root@docker1 web]# docker-compose up -d
Starting web_db_1 ... done
Starting web_wordpress_1 ... done

關閉的命令是downcss

[root@docker1 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官網介紹...................html

相關文章
相關標籤/搜索