# node
FROM node:14.18-alpine
# mirror
RUN echo 'http://mirrors.aliyun.com/alpine/v3.5/main' > /etc/apk/repositories
RUN echo 'http://mirrors.aliyun.com/alpine/v3.5/community' >>/etc/apk/repositories
# timeZone
RUN apk update && apk add tzdata
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
WORKDIR /app
COPY . /app
# npm
RUN yarn config set registry 'https://registry.npm.taobao.org' -g
RUN yarn config set sass_binary_site 'https://npm.taobao.org/mirrors/node-sass/' -g
RUN yarn install --network-timeout 600000
RUN yarn build
# script
CMD [ "yarn", "start" ]
two。 Execute the image build command:
docker image build -t myimage:v1 .
Note that there is one last point that cannot be omitted
- Run Mirror
docker run -d -p 3000:3000 -it myimage:v1
d means running in the background. Port 3000 inside the container is mapped to port 3000 outside the container.
- Run the container nning the container of the specified CONTAINER ID
docker start 684f23ec4ea9
docker images
lete the image of the specified IMAGE ID
docker rmi 597d72732244
docker ps -a
do not add-a to list only running containers
- Delete Container lete the container for the specified CONTAINER ID
docker rm dcf9dfaf355d
docker exec -it 4637c19a2d3a sh
Or
docker exec -it 4637c19a2d3a /bin/sh
Or
docker exec -it 4637c19a2d3a bash
Or
docker exec -it 4637c19a2d3a /bin/bash
ter exit to exit the container two。 Modify within the container For example, git update:
git pull
date the container after modification
Docker domestic accelerated image configuration
- Create a docker configuration folder
sudo mkdir -p /etc/docker
two。 Create a docker profile
sudo vi /etc/docker/daemon.json
Write the following
{
"registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com"]
}
tEase docker accelerated image
- Restart daemon
sudo systemctl daemon-reload
sudo systemctl restart docker
Windows:
Net stop com.docker.service
Net start com.docker.service