【DevOps|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 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
文章图片
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}
推荐阅读
- docker|《Docker+Kubernetes容器实战派》新书上市
- k8s学习总结|穷人安装ubuntu1.18.4+docker+kind+k8s-1.19.1+kubeflow-1.3
- Docker|Docker--本地镜像发布到私有库
- 目录索引|docker使用教程
- Docker 安装部署
- Linux之ack命令
- 涨粉写作经验分享 - 写作技巧
- 程序人生|程序员高考卷曝光,你能得多少分()
- Docker部署安装禅道