Created
January 2, 2019 04:34
-
-
Save trongvu/4ee991f3d3b069e89c9440b4d7d19f77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export image_name="android:5.0" | |
export container_name=${USER}_${image_name} | |
if [ ! "$(docker ps -q -f name=${container_name})" ] | |
then | |
if [ "$(docker ps -aq -f status=exited -f name=${container_name})" ]; then | |
# cleanup | |
docker rm ${container_name} | |
fi | |
# run your container | |
docker run --name ${container_name} -it --entrypoint /bin/bash -v /home/${USER}:/home/${USER} ${image_name} | |
else | |
docker exec -it "$(docker ps -q -f name=${container_name})" bash | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment