Skip to content

Instantly share code, notes, and snippets.

@pierangelo1982
Created September 16, 2017 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pierangelo1982/b8ae070a07ac8df4a123279eb6fc36a5 to your computer and use it in GitHub Desktop.
Save pierangelo1982/b8ae070a07ac8df4a123279eb6fc36a5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# a script that create a docker container
MYPATH=$1
echo "USAGE: script.sh [local_path]"
# check input parameters
if [ -z "$MYPATH" ]; then
echo "Error: local path is not set"
exit
fi
# create the path
echo "Insert the path of your volume: $MYPATH"
# pull the image
docker pull pierangelo1982/django
# create a volume
docker volume create --name django-test
# connect the volume to the container for can copy the project folder
docker run --name django-test \
-v django-test:/code \
-p 8001:8000 \
-d pierangelo1982/django
# copy project folders in your host
docker cp django-test:/code $MYPATH
# remove the container
docker rm -f django-test
# recreate the container with the volume that point to our local folder where before we have copy the folders of the project.
docker run --name django-test \
-v $MYPATH:/code \
-p 8001:8000 \
-d pierangelo1982/django
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment