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
相关推荐
龙鸣丿32 分钟前
Linux基础学习笔记
linux·笔记·学习
耶啵奶膘2 小时前
uniapp-是否删除
linux·前端·uni-app
闲晨3 小时前
C++ 继承:代码传承的魔法棒,开启奇幻编程之旅
java·c语言·开发语言·c++·经验分享
_.Switch3 小时前
高级Python自动化运维:容器安全与网络策略的深度解析
运维·网络·python·安全·自动化·devops
2401_850410833 小时前
文件系统和日志管理
linux·运维·服务器
JokerSZ.3 小时前
【基于LSM的ELF文件安全模块设计】参考
运维·网络·安全
XMYX-04 小时前
使用 SSH 蜜罐提升安全性和记录攻击活动
linux·ssh
芯盾时代4 小时前
数字身份发展趋势前瞻:身份韧性与安全
运维·安全·网络安全·密码学·信息与通信
幼儿园老大*4 小时前
Go的环境搭建以及GoLand安装教程
开发语言·经验分享·后端·golang·go
考试宝4 小时前
国家宠物美容师职业技能等级评价(高级)理论考试题
经验分享·笔记·职场和发展·学习方法·业界资讯·宠物