Giter Club home page Giter Club logo

nodejs-docker-image's Introduction

nodejs-docker-image

本代码演示了基于Docker创建一个简单的Node.js开发环境

代码使用方法

# 下载代码
git clone https://github.com/ijse/nodejs-docker-image.git
cd nodejs-docker-image

# 开发环境
## 构建镜像
docker build --force-rm -t ijse/nvm-dev -f ./Dockerfile_dev .

## 运行容器
docker run -it -v /nodejs-docker-image:/workspace --name my-project -p 3000:8080 ijse/nvm
## 此时会启动进入容器内的bash提示符,在这里可以安装程序依赖(对于容器平台),及启动调试程序
npm install && node index.js

# 生产环境
## 构建镜像
docker build --force-rm -t ijse/nvm -f ./Dockerfile .

## 运行容器
docker run --name my-project ijse/nvm

于是,容器中的程序便运行起来了

注意:

  • 如果是在Windows或Mac系统下,由于Docker是运行在虚拟机里的,所以访问时localhost要换为虚拟机的ip地址。
  • 可以通过docker inspect <container_id>来获取运行的container的ip和端口信息

更多内容

参照博客文章:http://www.ijser.cn/install-nvm-on-docker/

nodejs-docker-image's People

Contributors

ijse avatar

Watchers

 avatar  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.