docker镜像制作并部署
zeal 2020-08-20
# 打包docker镜像发布流程:
- 先登录私有账号
docker login --username=xxx@xxx registry.cn-qingdao.aliyuncs.com #这里用的是阿里云镜像
1
然后输入密码
your password
1
- 进入到项目的DockerFile文件目录
比如我的本地目录这样操作
cd /Users/zeal/Documents/work/code/zealsay_front
1
- 执行build命令打包
docker build -t 你的项目名:TAG .
1
注意:项目名称的命名空间为 registry.cn-qingdao.aliyuncs.com.
比如配置服务:
docker build -t registry.cn-qingdao.aliyuncs.com/xxx/zealsay_front:beta-1.0.0 .
1
- 推送到阿里云docker私有镜像服务
docker push 你的项目名:TAG
1
比如:
docker push registry.cn-qingdao.aliyuncs.com/xxx/zealsay_front:beta-1.0.0
1
相关dockerfile可以参照项目根目录的dockerfile文件,比如前端项目:
FROM node:10-alpine
ENV NODE_ENV=production
ENV HOST 0.0.0.0
COPY . /app
WORKDIR /app
EXPOSE 4000
#此为cnpm淘宝镜像
#RUN npm config set registry https://registry.npm.taobao.org
RUN npm install
RUN npm run build
CMD ["npm", "start"]
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11