前提:上篇文章中,已创建项目TestXujk,本篇详细讲述devops操作
通过将用户添加到docker用户组可以将sudo去掉,命令如下
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组
sudo ./svc.sh install root
currimages=$(docker images -a | grep "coreapp3" | awk ‘{print $3}‘)
if [ "${currimages}" != "" ]; then
docker rmi -f $(docker images -a | grep "coreapp3" | awk ‘{print $3}‘)
fi
#!/bin/bash
name="netcoreapp01"
cid=`docker inspect --format ‘{{.Id}}‘ ${name} 2>/dev/null`
if [[ ${#cid} -gt 0 ]]; then
docker stop $name
docker rm $name
echo "successed deleted container ${name}"
fi
docker run -it -d -p 8002:80 --name netcoreapp01 --privileged=true coreapp3:$(Build.BuildId)
docker logs netcoreapp01
Azure 实践(3)- Azure Devops构建.netcore项目,打包Docker镜像+运行容器部署
原文:https://www.cnblogs.com/kunwn/p/15212912.html