首页 > 其他分享 >docker-compose

docker-compose

时间:2023-01-07 18:11:23浏览次数:38  
标签:ghost compose nginx 2368 docker config

一、安装

下载安装

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.4.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

权限设置

sudo chmod +x /usr/local/bin/docker-compose

创建软连接

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

测试是否安装成功

docker-compose version

二、实战

目标:nginx->app->mysql

创建三个文件夹:nginx,ghost,data以及一个文件docker-compose.yaml

在ghost目录创建:config.js以及Dockerfile

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;

Dockerfile

FROM ghost
COPY ./config.js /var/lib/ghost/config.js
EXPOSE 2368
CMD ["npm","start","--production"]

 在nginx目录下创建nginx.conf以及Dockerfile

nginx.conf

worker_processes  4;
events {
    worker_connections  1024;
}
http {
    server {
        listen       80;
      
        location / {
            proxy_pass http://ghost-app:2368;
        }
    }
}

 

 Dockerfile

FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

 

编写docker-compose.yaml

version: '2'
networks: 
  gost:

services:
  ghost-app:
    build: ghost
    networks:
      - ghost
    depends_on:
      - db
    ports:
      - "2368:2368"      
  nginx:
    build: nginx
    networks:
      - ghost
    depends_on:
      - ghost-app
    ports:
      - "80:80"
  db:
    image: "mysql:5.7.15"
    networks:
      - ghost
    environment:
      MYSQL_ROOT_PASSWORD: mysqlroot
      MYSQL_USER: ghost
      MYSQL_PASSWORD: ghost
    volumes:
      - $PWD/data:/var/lib/mysql
    ports:
      - '3306:3306'

 

 执行命令:

docker-compose up -d

 

标签:ghost,compose,nginx,2368,docker,config
From: https://www.cnblogs.com/excellencesy/p/17033143.html

相关文章

  • Compose跨平台第一弹:体验Compose for Desktop
    前言Compose是Android官方提供的声明式UI开发框架,而ComposeMultiplatform是由JetBrains维护的,对于Android开发来说,个人认为学习JetpackCompose是必须的,因为它会成为Andro......
  • linux安装docker
    https://blog.csdn.net/Pratik_shiku/article/details/124309852?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167308260416782427492732%2522%252C%2522scm......
  • K8s 为什么会抛弃 docker
    为什么K8s会抛弃docker前言CRIcontainerd参考为什么K8s会抛弃docker前言在这之前先来了解下,k8s是如何和docker进行交互的。CRIkubelet调用下层容......
  • docker-Volume
    volume:提供独立于容器之外的持久化存储一、持久化地址dockerrun-d--namenginx-v2-v/usr/share/nginx/htmlnginxinspect检查返回容器的所有信息(Mounts.Source......
  • Docker 系列(3) —— 切换 Docker 镜像源Docker 系列(3) —— 切换 Docker 镜像源
    Docker添加国内镜像源windows版Step1打开Dockerforwindows{"registry-mirrors":["https://7bezldxe.mirror.aliyuncs.com/","https://dock......
  • DockerFile
    一个简单的示例FROMalpine:latestMAINTAINERsongyanCMDecho'hellodocker'创建镜像dockerbuild-thello_docker-ftest.dockerFile.运行这个镜像docke......
  • Docker镜像的基本操作总结
    摘要容器化是上个十年比较火的技术.现在看起来在进行总计有点晚了.不过linux是三十年前的,我依旧没有总结好道理是一样的.技术不在于新旧,重要的是学习到原理.Doc......
  • docker开启远程访问
    说明如果你的服务器是公网IP,并且开放了docker的远程访问,如果没有进行保护是非常危险的,任何人都可以向你的docker中推送镜像、运行实例。我曾开放过阿里云服务器中docker的......
  • Docker(一):Linux安装Docker
    参考地址:https://blog.csdn.net/weixin_43526371/article/details/125811270下载DockerEnginehttps://docs.docker.com/engine/install/centos/查看系统版本$cat/etc......
  • Docker(二):镜像、容器 - 基础命令
    参考地址:https://blog.csdn.net/weixin_43526371/article/details/125811320镜像命令#基础信息$dockerinfo#镜像列表$dockerimages#image全部列表$dockerimage......