FROM node:16-alpine ADD . ./app WORKDIR /app # RUN npm install CMDpwd && ls && echo"启动服务~" && node ehandbook.js
构建镜像
1
➜ ehandbook docker build -t ehandbook:v0.0.1 .
运行容器
1
➜ ehandbook docker run -p 8888:8888 --name ehandbookcon ehandbook:v0.0.1
push镜像到hub
首先要登录(梯子
1 2 3 4 5 6 7
➜ ehandbook docker login Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one. You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/
Username: 你的用户名 Password: 密码直接回车 Login Succeeded
1 2 3 4 5 6 7 8
# 对本地镜像要打一个tag ➜ ehandbook docker tag ehandbook:v0.0.1 weimo9/ehandbook:v0.0.1 # 检查一下 ➜ ehandbook docker images REPOSITORY TAG IMAGE ID CREATED SIZE weimo9/ehandbook v0.0.1 df836bb667c9 19 minutes ago 136MB ehandbook v0.0.1 df836bb667c9 19 minutes ago 136MB weimo9/koa-test latest a87090af61aa 22 months ago 117MB
直接挂梯子push
1 2 3 4 5 6 7 8
➜ ehandbook docker push weimo9/ehandbook:v0.0.1 The push refers to repository [docker.io/weimo9/ehandbook] 5f70bf18a086: Pushed 15111b888f32: Pushing 19.86MB fabb6e7cc132: Retrying in 5 seconds 46e75cb9d01b: Pushed 525e899ff770: Pushing 69.58MB/101.1MB b2191e2be29d: Retrying in 7 seconds