Saber2pr's Blog


  1. Write Dockerfile, for example:
# node
FROM node:14.18-alpine

# mirror
RUN echo '' > /etc/apk/repositories
RUN echo '' >>/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

COPY . /app

# npm
RUN yarn config set registry '' -g
RUN yarn config set sass_binary_site '' -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

  1. 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.

  1. Run the container nning the container of the specified CONTAINER ID
docker start 684f23ec4ea9
  1. List existing mirrors
docker images
  1. Delete the mirror:

lete the image of the specified IMAGE ID

docker rmi 597d72732244
  1. View existing containers
docker ps -a

do not add-a to list only running containers

  1. Delete Container lete the container for the specified CONTAINER ID
docker rm dcf9dfaf355d

Docker Container Update

  1. Enter the container bash
docker exec -it 4637c19a2d3a sh


docker exec -it 4637c19a2d3a /bin/sh


docker exec -it 4637c19a2d3a bash


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

  1. 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": [""]

tEase docker accelerated image

  1. Restart daemon
sudo systemctl daemon-reload
  1. Restart docker
sudo systemctl restart docker


Net stop com.docker.service
Net start com.docker.service