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
相关推荐
行思理1 分钟前
Linux 下SVN新手操作手册
linux·运维·svn
初学者丶一起加油13 分钟前
C语言基础:指针(数组指针与指针数组)
linux·c语言·开发语言·数据结构·c++·算法·visual studio
ether-lin37 分钟前
DevOps实战:用Kubernetes和Argo打造自动化CI/CD流程(1)
ci/cd·kubernetes·devops
嘤嘤怪呆呆狗40 分钟前
【开发问题记录】使用 Docker+Jenkins+Jenkins + gitee 实现自动化部署前端项目 CI/CD(centos7为例)
前端·vue.js·ci/cd·docker·gitee·自动化·jenkins
沛沛老爹43 分钟前
CI/CD是什么?
运维·git·ci/cd
一只搬砖的猹1 小时前
cJson系列——常用cJson库函数
linux·前端·javascript·python·物联网·mysql·json
IPdodo全球网络服务1 小时前
如何通过TikTok引流到私域流量池
运维·服务器·网络
莫固执,朋友2 小时前
Linux下编译 libwebsockets简介和使用示例
linux·websocket·音视频
IT 古月方源2 小时前
关于高级acl的配置和讲解
运维·开发语言·网络·tcp/ip·智能路由器
DCTANT2 小时前
【合作原创】使用Termux搭建可以使用的生产力环境(八)
linux·debian·idea·termux·vnc·xfce4·termux-x11