• 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
  • 相关阅读:
    Kubernetes学习笔记-一
    2024 Web 新特性 - 使用 Popover API 创建弹窗
    ubuntu安装nvm
    如果老师这么讲面向对象,当年我就不会挂科了吧
    VoLTE基础自学系列 | 企业语音网简述
    GBase 8c 存储技术---列存储引擎(二)
    SendKeys.SendWait 函数模拟键盘输入
    testcontainers-java 新增对 TiDB 的支持
    Python小练03
    babel:无法将“babel“项目识别问题
  • 原文地址:https://blog.csdn.net/zjy997/article/details/132820531