Skip to content

Instantly share code, notes, and snippets.

@eslam-mahmoud
Last active January 24, 2019 23:54
Show Gist options
  • Save eslam-mahmoud/60b24edea3acd832ee8a3b8eec0dc754 to your computer and use it in GitHub Desktop.
Save eslam-mahmoud/60b24edea3acd832ee8a3b8eec0dc754 to your computer and use it in GitHub Desktop.
sh script to stop current container and remove it and rebuild the image and run the container, can be used after pull new code
#from https://stackoverflow.com/questions/41322541/rebuild-docker-container-on-file-changes
#!/bin/bash
imageName=app
containerName=app-container
docker build -t $imageName -f Dockerfile .
echo Delete old container...
docker rm -f $containerName
echo Run new container...
docker run -d -p 80:80 --name $containerName $imageName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment