用docker-compose部署wordpress博客系統

先搞定docker-compose,使它可以使用:
[root@localhost ~]# curl -L https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-`uname -s-uname -m` -o /usr/local/bin/docker-compose
[root@localhost ~]# chmod +x /usr/local/bin/docker-compose
[root@localhost ~]# docker-compose -v
docker-compose version 1.25.1-rc1, build d92e9beemysql

須要兩個包,個人是下面的本地包,大家也可再網上下載,不過要注意版本號:
用docker-compose部署wordpress博客系統
將他們作成鏡像:
[root@localhost ~]# docker load < mysql-5.7.tar
[root@localhost ~]# docker load < wordpress.tar git

得出如下兩個鏡像:
用docker-compose部署wordpress博客系統github

建立一個目錄,再目錄裏面寫入docker-compose.yml文件:
[root@localhost ~]# mkdir wordpress
[root@localhost ~]# cd wordpress/
[root@localhost wordpress]# vim docker-compose.yml
version: "3.1"
services:
wordpress:
image: wordpress
restart: always
ports:sql

  • 8080:80
    environment:
    WORDPRESS_DB_HOST: db
    WORDPRESS_DB_USER: wordpress
    WORDPRESS_DB_PASSWORD: 123.com
    WORDPRESS_DB_NAME: wordpress
    db:
    image: mysql:5.7
    restart: always
    environment:
    MYSQL_DATABASE: wordpress
    MYSQL_USER: wordpress
    MYSQL_PASSWORD: 123.com
    MYSQL_ROOT_PASSWORD: 123.comdocker

    啓動容器:
        [root@localhost wordpress]# docker-compose up -d
        最後瀏覽器訪問:ip地址加端口8080:

用docker-compose部署wordpress博客系統
瀏覽器訪問不了是由於沒有開啓路由轉發。開啓就好,如下命令:
[root@localhost wordpress]# echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
[root@localhost wordpress]# systemctl restart network
就能夠訪問了vim

相關文章
相關標籤/搜索