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
相关推荐
森焱森2 分钟前
嵌入式硬件工程师应知 白银快速分析报告
linux·c语言·arm开发·嵌入式硬件·去中心化
忆~遂愿4 分钟前
Runtime 上下文管理:计算实例的生命周期、延迟最小化与上下文切换优化
java·大数据·开发语言·人工智能·docker
zhyf1196 分钟前
AU软件安装详细步骤梳理(win&mac)
经验分享
消失的旧时光-19437 分钟前
Nginx 是什么?为什么它不写在代码里?——从 0 认识 Nginx
运维·服务器·nginx
BJ_Bonree8 分钟前
4月17日,博睿数据受邀出席GOPS全球运维大会2026 · 深圳站!
大数据·运维·人工智能
RisunJan9 分钟前
Linux命令-lpq(查看打印队列状态)
linux·运维·服务器
山君爱摸鱼10 分钟前
Linux-服务进程
linux·运维·服务器
阿乐艾官11 分钟前
【linux文件系统重要目录及命令解释】
linux·运维·服务器
blueSatchel13 分钟前
U-Boot启动后做的事情
linux·u-boot
senijusene17 分钟前
Linux软件编程: Linux 操作系统基础与shell脚本
linux·运维·chrome