A Dockerfile lets you build your own image, usually based on an existing image, then installing some extra libraries (the ones you need)
Dockerfile can build own image that base on a basic image and install some libraries that you need
- The following base on node:11 and
FROM node:11
MAINTAINER easydoc.net
# Copy the code
ADD . /app
# Set the default working directory after the container starts
WORKDIR /app
# Run commands to install dependencies
# There can be multiple RUN commands, but you can join several commands with && to reduce layers.
# e.g. RUN npm install && cd /app && mkdir logs
RUN npm install --registry=https://registry.npm.taobao.org
# There can be only one CMD instruction; it is the command run after the container starts, i.e. the program's entry point.
# If you need to run other commands, join them with &&, or put them in a shell script and run that.
# e.g. CMD cd /app && ./start.sh
CMD node app.js
Run docker build -t test:v1 .
- -t specifies the version tag
- . is the directory containing the Dockerfile, here the current directory
- You can also install node11 first, then enter the system and install some packages; just write all the package-installation steps into a Dockerfile