工具相关的启动

 
  1. imgname=redis:latest
  2. containerName=redis6379
  3. port=6379
  4. echo stop 容器........................................
  5. docker stop $(docker ps -qf name=$containerName)
  6. echo 删除容器.....................................
  7. docker rm $(docker ps -aqf name=$containerName)
  8. echo 运行 镜像..................................................
  9. docker run -d --name=$containerName -p $port:$port $imgname

自己的程序:

 
  1. imgname=docker-test-1.0.jar
  2. port=8320
  3. echo stop 容器........................................
  4. docker stop $(docker ps -qf name=$imgname)
  5. echo 删除容器.....................................
  6. docker rm $(docker ps -aqf name=$imgname)
  7. echo 删除镜像.............................................
  8. docker images|grep $imgname |awk '{print $3}'|xargs docker rmi
  9. echo 生成镜像...................................................
  10. docker build -t $imgname .
  11. echo 运行 镜像..................................................
  12. docker run -d --name=$imgname -p $port:$port -v ~/opt/logs/$imgname:/root/opt/logs $imgname
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐