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

推荐订阅源

V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
Netflix TechBlog - Medium
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
V
V2EX
IT之家
IT之家
J
Java Code Geeks
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
D
Docker
S
Secure Thoughts
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
博客园_首页
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
I
InfoQ
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
W
WeLiveSecurity
T
Troy Hunt's Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Scott Helme
Scott Helme
T
Tor Project blog
Know Your Adversary
Know Your Adversary
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
G
Google Developers Blog

博客园 - 远洪

大模型常用术语 windows 使用sshAgent 加载秘钥 再次认识java反射 再次认识java注解 再次认识java泛型 java中类的分类 java类中的成员变量,静态变量与局部变量 再谈java枚举enum 使用CCProxy让手机访问电脑能访问的网址 playwright启动后报错net::ERR_CERT_COMMON_NAME_INVALID 解决方法 debian 或ubuntu安装使用tigervnc python 实例属性、类属性、实例方法、类方法、静态方法 python面向对象封装,私有变量 docker compose使用 docker 自定义网络 golang进程(主线程)与协程 go语言多态中的类型断言 java中的多态与golang中的多态 golang 定义接口
Dockerfile 使用
远洪 · 2024-02-21 · via 博客园 - 远洪

dockerfile编写详见:https://www.cnblogs.com/liyuanhong/articles/13265836.html

使用dockerfile 创建一个node应用的镜像

编写一个app.js 的文件,代码如下:

var http = require("http");
http.createServer(function(request,response){
    response.writeHead(200,{"Content-Type":"text/plain"});
    response.write("hello my first demo\n");
    response.end();
}).listen("8080");
console.log("server start");

在当前目录添加 Dockerfile文件如下:

# 使用node的最新镜像
FROM node
# 暴露容器端口号为:8080
EXPOSE 8080
# 在容器内创建一个 /home/app
RUN mkdir /home/app
# 设置工作目录为: /home/app
WORKDIR /home/app
# 将本地当前目录文件添加到容器的  /home/app 目录
ADD . /home/app
# 启动容器后运行的命令
CMD ["node","app.js"]

使用当前目录下的Dockerfile文件构建镜像:

docker build -t nodeapp:v1.0 .

前台启动构建好的镜像:

docker run -p 8080:8080 nodeapp:v1.0

 访问启动的服务: