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:

  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

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

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

  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

  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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值