• Docker笔记


    来自于Youtube Net Ninja 的Docker Crash Course。

    Docker是一个轻量级(lightweight)的“虚拟机”。它可以让队伍不同的成员在相同的环境下运行应用。

    image: 是container的blueprint(蓝图)。像是装修时的脚手架,是建筑的外壳。Image说明了container的配置。Image可以理解为Container的说明书,是用来配置Container的。

    container:Docker的运行实例。实际应用在container中运行。

    Dockerfile(就是这个名字,不用后缀):配置自己的image时需要的文件。程序配置时会一行一行运行dockerfile中的内容,搭建自己的image。

    1. // Parent image as the base
    2. FROM node:17-alpine
    3. // Set working directory
    4. WORKDIR /app
    5. // copy current terminal files to docker working directory
    6. COPY . .
    7. // RUN means to run the following command during the building time
    8. RUN npm install
    9. // Expose the port
    10. EXPOSE 4000
    11. // CMD means to run the following command during the run time of the container instance.
    12. CMD ["node", "app.js"]

    .dockerignore:这里列出不需要被COPY这个命令拷贝到image中的内容(例如node_modules,敏感内容,日志等)。

    写法:一行一个。

    node_modules

    *.md

    这句话用来创建一个新的image. -t 代表 -tag,用来命名。最后一个.指的是把当前目录下所有文件放进image。

    docker build -t myapp .

    这句话用来创建一个新container。 --name 代表给新container命名, -p代表指定port。左边的4000代表本地计算机上的port,右边的代表container expose的port。最后是image的名字。

    docker run --name myapp5_c -p 4000:4000 myapp5
  • 相关阅读:
    什么是BI报表?
    帖子求助:两台电脑时间相差1或2秒
    朝夕光年「红砖」搭建平台架构设计和应用落地
    如何截取视频中的一段视频?分享几种视频分割方法
    3dmax中格式批量互转obj批量转fbx等等
    热修复技术可谓是百花齐放
    unity自定义着色器基础
    C++ 基础面试题总结(一)
    python爬虫-Selenium
    大数据实战之前戏
  • 原文地址:https://blog.csdn.net/zjy997/article/details/132820531