Giter Site home page Giter Site logo

docker_demo's Introduction

安装docker(国内)

# 将https://download.docker.com 改为 github的一个地址
curl -fsSL https://raw.githubusercontent.com/ruicky/docker_demo/master/install_dock.sh  -o get-docker.sh
# 安装时 选择 阿里云镜像
sudo sh get-docker.sh --mirror Aliyun

项目初衷

  1. 构建Nodejs + Express 项目的Docker镜像
  2. 测试Nginx反向代理到多个APP的配置

上图 说明: 流程示意图

前提条件

  1. NodeJS
  2. Docker

快速开始

cd App1 && docker build -t nodejs_app_1 .
docker run -p 3100:3100  -d --name nodejs_app_1 nodejs_app_1

访问 http://localhost:3100 OR http://localhost:3200

主要代码

FROM registry.cn-hangzhou.aliyuncs.com/zuowenbo/nodejs


# 安装pm2守护进程
RUN npm install pm2 -g -verbose --registry=https://registry.npm.taobao.org

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app



# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install -verbose --registry=https://registry.npm.taobao.org


# Bundle app source
COPY . /usr/src/app


# 端口
EXPOSE 3100


# 默认执行(可被运行时重写)
CMD ["pm2","start", "ecosystem.config.js","--no-daemon"]

# 构建命令
# docker build -t nodejs_app_1 .

# 运行命令
# docker run -p 3100:3100  -d --name nodejs_app_1 nodejs_app_1

nginx 部分

  1. 需要修改host文件,以mac为例 sudo vim /etc/hosts 做测试

遗留

目前测试的宿主机是一台。如果是多台并且docker是多个实例有待完善。

docker_demo's People

Contributors

ruicky avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.