Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jenkins 执行dockerfile #45

Open
tjlizz opened this issue Apr 9, 2021 · 0 comments
Open

jenkins 执行dockerfile #45

tjlizz opened this issue Apr 9, 2021 · 0 comments

Comments

@tjlizz
Copy link
Owner

tjlizz commented Apr 9, 2021

#!/bin/bash
name=protal
#判断是否容器存在
sudo docker ps -a | grep $name &> /dev/null
#如果存在,关闭并删除该容器
if [ $? -eq 0 ]
then
    echo $name" is up,we will stop and remove it!!!"
    docker stop $name
    docker rm $name
else
    echo $name" is not up!!!"
fi

#判断是否镜像存在
sudo docker images | grep $name &> /dev/null
#如果存在,删除该镜像
if [ $? -eq 0 ]
then
    echo $name" image is existed,we will remove it!!!"
    docker rmi $(docker images | grep $name | awk "{print $3}")
else
    echo $name" image is not existed!!!"
fi
docker build -t protal .
docker run    -itd --name protal  -e "SPRING_PROFILES_ACTIVE=prod" -p 3579:3579    -v /opt/file:/opt/file  protal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant