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
相关推荐
魏 无羡几秒前
k8s ssl 漏洞修复
容器·kubernetes·ssl
千墨16 分钟前
VMware安装Centos 9虚拟机+设置共享文件夹+远程登录
linux·运维·centos
白水先森18 分钟前
ArcGIS Pro进行坡度与坡向分析
经验分享·arcgis
hjnjmjkj24 分钟前
基于windows的docker-desktop安装kubenetes以及dashboard
docker·容器·kubernetes
Libby博仙1 小时前
docker 改了镜像源为阿里云,还是下载失败
阿里云·docker·容器
ChinaRainbowSea1 小时前
1. Linux下 MySQL 的详细安装与使用
linux·数据库·sql·mysql·adb
网络安全(华哥)2 小时前
网络安全服务实施流程管理 网络安全服务体系
运维·服务器·网络
致奋斗的我们2 小时前
Nginx反向代理及负载均衡
linux·运维·mysql·nginx·负载均衡·shell·openeluer
百锦再2 小时前
在Linux上创建一个Docker容器并在其中执行Python脚本
linux·python·docker
Ares-Wang2 小时前
负载均衡 方式
运维·负载均衡