亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

【6-3 compose實戰】2022-03-10成功運行說明(1)各個鏡像的內容和配置文件的內容

首先,對前面評論和提問題的小伙伴表示感謝,他們給我了很多提示和信息。

另外,要說明的是,因為大家都是初學者,老師給的例子沒有指定ghost的版本,所以拉取的會是最新版本,所以很有可能我下面的說明隨著ghost新的版本更新也會有一些問題,無法運行。

但是現在測試是沒有問題的,我完全跑起來了,也寫下來給后來的小伙伴們分享。


首先是ghost鏡像的Dockerfile內容:

FROM ghost:3-alpine

COPY ./config.js /var/lib/ghost/content/config.js

EXPOSE 2368

接下來是配置文件config.js:

var path = require('path'),

config;

?

config = {

? production: {

??? url: 'http://mytestblog.com',

??? mail:{},

??? database:{

??????? client: 'mysql',

??????? connection: {

??????????? host: 'db',

??????????? user: 'ghost',

??????????? password: 'ghost',

??????????? database: 'ghost',

??????????? port: '3306',

??????????? charset: 'utf8'

??????? },

??????? debug: false

??? },

??? paths: {

??????? contentPath: path.join(process.env.GHOST_CONTENT, '/')

??? },

??? server: {

??????? host: '0.0.0.0',

??????? port: '2368'

??? }

? }

};

?

module.exports = config;

nginx鏡像文件內容:

FROM nginx

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80

nginx配置文件內容:

worker_processes 4;

events {

??? worker_connections 1024;

}

http {

??? server {

??????? listen 80;

??????? location / {

??????????? proxy_pass http://ghost-app:2368;

??????? }

??? }

}

docker-compose.yml文件的內容:

version: '3.1'

networks:

? ghost:

services:

? nginx:

??? build: nginx

??? networks:

????? - ghost

??? ports:

????? - "80:80"

??? depends_on:

????? - ghost-app

? ghost-app:

??? build: ghost

??? networks:

????? - ghost

??? depends_on:

????? - db

??? restart: always

??? ports:

????? - "2368:2368"

??? environment:

????? database__client: mysql

????? database__connection__host: db

????? database__connection__user: ghost

????? database__connection__password: ghost

????? database__connection__database: ghost

? db:

??? image: mysql:5.7.15

??? restart: always

??? networks:

????? - ghost

??? volumes:

????? - $PWD/data:/var/lib/mysql

??? ports:

????? - "3306:3306"

??? environment:

????? MYSQL_ROOT_PASSWORD: example

????? MYSQL_USER: ghost

????? MYSQL_PASSWORD: ghost


正在回答

舉報

0/150
提交
取消

【6-3 compose實戰】2022-03-10成功運行說明(1)各個鏡像的內容和配置文件的內容

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號