How to start the dotnetsdk docker image for test?

Following the last articleHow to run a Docker on Windows 10 with WSL?https://blog.csdn.net/wish366/article/details/125011890

 1. Start wsl2 and docker

# showing docker status
service docker status

# start docker service by root
sudo service docker start

 2.Download the dotnetsdk docker image

Command: 
  docker pull {the image path of your repository}

For example: 
  docker pull harbor-k8s.xxx.com/base_image/dotnetsdk:3.1

 

   2.1 If it's showing the error: x509: certificate signed by unknown authority

    Add the setting as following into /etc/docker/daemon.json.

  {  
     "insecure-registries":["https://harbor-k8s.xxx.com"]
  }

   2.2 Then restart your docker service

Command: 
  sudo service docker restart

  2.3 If you have no permission to download, please try to login first

  Command: docker login -u "{your account}" -p "{your password}" {your repository}
           docker pull {the image path of your repository}
           docker logout {your repository}
  For example: docker login -u "userid" -p "password" harbor-k8s.xxx.com
               docker pull harbor-k8s.xxx.com/base_image/dotnetsdk:3.1
               docker logout harbor-k8s.xxx.com

3.Start the docker container and enter (Docker run)

Command: docker run -it -v {local path of wsl}:{container path} --rm --name {docker image name} 
    How to get a docker image name that you need, please enter the command: docker images
    Hwo to enter the local path of wsl from Windows, please enter the command: \\wsl$\Ubuntu-18.04
    -v: --volume
    --rm: If you exit the docker container, it will not be showed. command: docker ps -a 
For example: docker run -it -v /tmp/ut:/ut --rm --name dotnetsdk harbor-k8s.xxx.com/base_image/dotnetsdk:3.1 

 4.Enter the path in container that you want to test

For example: cd /ut/API/UT.test

5.Test

For example: run a UT
    dotnet add package Toolkit -s http://nuget.xxx.com/nuget/
    dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:UseSourceLink=true /p:CoverletOutput=/ut/API/TestResults/ /p:ThresholdType=line

6. Result

7. Appendix

# Show docker container
docker ps -a
 
# Delete docker container
docker rm {container ID}
 
# Show docker image
docker images
 
# Delete docker image
docker rmi {image ID}
 
# Go to Ubuntu from Windows
\\wsl$\Ubuntu-18.04

# showing docker status
service docker status
 
# start docker service by root
sudo service docker start

# stop docker service by root
sudo service docker stop 

# Delete a folder
rm -rf {directory name}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值