DevOps|How to start the dotnetsdk docker image for test?

【DevOps|How to start the dotnetsdk docker image for test?】Following the last articleHow to run a Docker on Windows 10 with WSL?DevOps|How to start the dotnetsdk docker image for test?
文章图片
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

DevOps|How to start the dotnetsdk docker image for test?
文章图片

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

DevOps|How to start the dotnetsdk docker image for test?
文章图片

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"] }

DevOps|How to start the dotnetsdk docker image for test?
文章图片

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 be not 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

DevOps|How to start the dotnetsdk docker image for test?
文章图片

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
DevOps|How to start the dotnetsdk docker image for test?
文章图片

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}


    推荐阅读