惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - 草珊瑚

前端git开发分支各种场景管理 RxJS Subject学习 微信小程序登陆流程(20200322) vue依赖收集的策略 eggjs2.x版本异步获取config配置方案 - 草珊瑚 - 博客园 dubbo连接过程 计算机中对流的理解 Egg.js运行环境配置场景 Promise和Observable的映射 eggjs异常捕获机制 极客时间数据结构与算法之美笔记7 JS项目快速压缩(windows平台) - 草珊瑚 - 博客园 JS项目快速压缩(windows平台) - 草珊瑚 - 博客园 Maven工程的POM继承 win10家庭版安装Docker for Windows linux,vim和bash命令小册 vue文档阅读笔记——计算属性和侦听器 nodejs的jekins部署 `vue-router`的`History`模式下的项目发布
Docker构建一个node镜像
草珊瑚 · 2019-03-21 · via 博客园 - 草珊瑚

0. 设置国内docker镜像源

进入Settings->Daemon->Advanced,添加如下配置。

{
  "registry-mirrors": [
    "http://hub-mirror.c.163.com",
    "https://registry.docker-cn.com",
    "http://f1361db2.m.daocloud.io"
  ],
  "insecure-registries": [],
  "debug": true,
  "experimental": true
}

点击Apply,等待Docker重启。

1. 拉取官方alpine最新版本镜像

docker pull alpine:latest

2. 新建一个Dockerfile文件

FROM alpine

RUN apk update \
    && apk add nodejs \
    && apk add npm 

进入Settings->Shared Drives勾选共享的硬盘,输入系统登录的用户名和密码,点击Apply。

问题:点击Apply后,无法生效。

解决办法:
win+R ,键入gpedit.msc,出现如下界面,找到高亮处的网络访问:本地账户的共享和安全模型,选择如图中的经典选项即可。

4. 构建镜像

在Dockerfile文件当前目录下执行cmd命令

 docker build -t node:v1 .

在Dockerfile文件当前目录下新建一个index.js文件

console.log('hello docker');

5. 启动容器

假设前面的Dockerfile文件和index.js文件都在c:/test/docker/node目录下。
执行cmd命令

docker run --rm -v c:/test/docker/node:/data node:v1 node /data/index.js