1.使用Ghost-Docker 构建博客并配置Mysql数据库

2018-02-12  本文已影响0人  Peacenloves

1. 安装Docker

    yum -y install docker
    service docker start

2. 使用Docker安装Ghost镜像

    docker pull ghost
    docker images

REPOSITORY:仓库地址
TAG:版本
IMAGE ID:镜像编号
    docker run -d --name ${names} -p 80:2368 -d ${image}
    #${names}: 容器启动后自定义名称
    #${image}: 启动镜像ID-对应下载的镜像
    docker ps -a

COMMAND:指令,entrypoint使容器表现类似可执行程序,可以传递参数
PORTS:本机端口到docker容器映射关系

3. 使用Mysql数据库

  1. 进入Docker-Ghost容器
    docker exec -it ${container_id} /bin/bash
    #更新apt-get
    apt-get update
    #安装vim
    apt-get install vim 
    cd /var/lib/ghost/current/core
    vim index.js
    // ## Server Loader
    // Passes options through the boot process to get a server instance back
    var server = require('./server');

    // 将下面的`development`修改为`production`
    process.env.NODE_ENV = process.env.NODE_ENV || 'production';

    function makeGhost(options) {
        options = options || {};

        return server(options);
    }

    module.exports = makeGhost;
    {
        "database": {
            "client": "mysql",
            "connection": {
                "host"     : "172.17.0.1",
                "user"     : "",
                "password" : "",
                "database" : ""
            }
        },
        "paths": {
            "contentPath": "content/"
        },
        "logging": {
            "level": "info",
            "rotation": {
                "enabled": true
            },
            "transports": ["file", "stdout"]
        }
    }
    docker inspect ${container_id}
    "Networks": {
        "bridge": {
            "IPAMConfig": null,
            "Links": null,
            "Aliases": null,
            "NetworkID":     "",
            "EndpointID": "",
            "Gateway": "172.17.0.1",
            "IPAddress": "172.17.0.3",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "MacAddress": ""
        }
    }
    docker stop ${container_id}
    docker start ${container_id}
上一篇 下一篇

猜你喜欢

热点阅读