How to push a docker image to harbor on wsl?

1.Create a new project using .NET5.

For example: my project is Test20221123.

2.Add a Dockerfile in this project, the file contents as below:

bash 复制代码
  FROM harbor.xxx.com/dotnet/aspnet:5.0
  MAINTAINER XXX
  ENV ASPNETCORE_ENVIRONMENT=Development
  ENV TZ=Asia/Shanghai
  ENV LANG=en_US.UTF-8
  WORKDIR /app
  #RUN dotnet restore
  #RUN dotnet publish -c Release -o out -r linux-x64
  RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
  RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf
  COPY ./out .
  ENV ASPNETCORE_URLS http://0.0.0.0:80
  ENTRYPOINT ["dotnet", "Test20221123.dll"]

3.Publish the project, please using the following command:

dotnet publish -c Release -o out -r linux-x64

cs 复制代码
dotnet publish -c Release -o out -r linux-x64

4.Open you wsl and logon with administrator, then execute the commands as below:

bash 复制代码
  sudo service docker start
  cd /mnt/d/SourceCode/GitLab/Test20221123
  docker login -u "userid" -p "password" harbor.xxx.com
  docker build -f Dockerfile -t "harbor.xxx.com/demo/my-app.job:develop-00001" .
  docker push "harbor.xxx.com/demo/my-app.job:develop-00001"
  docker logout "harbor.xxx.com"

5.Check the docker image which you just pushed on harbor.

6.Deploy a workload on rancher.

7.Troubleshooting

bash 复制代码
  7.1 show the error: 'x509: certificate signed by unknown authority'
    echo -n | openssl s_client -showcerts -connect harbor.xxx.com:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/ssl/certs/harbor.xxx.com.crt
相关推荐
Tokai_Teio_137 分钟前
第四届黄河流域 misc
运维·服务器
开发者联盟league1 小时前
使用k8s安装Sonarqube
云原生·容器·kubernetes
hj2862511 小时前
Linux 网络服务综合笔记(概念 + 命令 + 实操案例)2
linux·运维·网络
what_20181 小时前
Linux 磁盘 (查看、划分、inode)
linux·运维·服务器
ManageEngine卓豪1 小时前
从性能故障到安全风险,现代企业数字化转型下的网络丢包运维管控指南
运维·网络安全·网络故障·网络丢包
2739920291 小时前
GDB调试(Linux)
linux
ai产品老杨2 小时前
架构师深剖:基于 Docker 容器化与边缘计算的 AI 视频管理平台——支持 GB28181/RTSP 多协议接入与全源码交付
人工智能·docker·边缘计算
凡人叶枫2 小时前
Effective C++ 条款23:宁以 non-member、non-friend 替换 member 函数
linux·开发语言·c++·嵌入式开发
不会C语言的男孩2 小时前
Linux 系统编程 · 第 4 章:文件属性与元数据
linux·c语言·开发语言
小生不才yz2 小时前
Shell脚本精读 · S02-03 | 词拆分、通配符与未加引号的变量
linux