Docker笔记

来自于Youtube Net Ninja 的Docker Crash Course。

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

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

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

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

// Parent image as the base
FROM node:17-alpine

// Set working directory
WORKDIR /app

// copy current terminal files to docker working directory
COPY . .

// RUN means to run the following command during the building time
RUN npm install

// Expose the port
EXPOSE 4000

// CMD means to run the following command during the run time of the container instance.
CMD ["node", "app.js"]

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

写法:一行一个。

node_modules

*.md

你可能感兴趣的:(docker,笔记,容器)