Last active
August 29, 2015 14:16
-
-
Save ashokfernandez/33034d7c841f6df76951 to your computer and use it in GitHub Desktop.
Build and run a docker image, then open a bash shell inside the running container
This file contains hidden or 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 | |
docker stop $(docker ps -a -q) # Stop and close any running docker containers | |
docker rm $(docker ps -a -q) | |
docker build -t myapp . # Build and run the container | |
docker run --name mydockerapp -d -p 80:80 myapp | |
docker exec -it mydockerapp bash # Open a bash terminal on the running container |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To exit the bash shell just type
exit
. Next time you run the script the old running container will be shutdown before being rebuilt and started again.