[FIX] Stop using --volumes-from option from Docker

master
Olivier DOSSMANN 2017-01-24 16:55:24 +01:00
parent 975f00168a
commit f8ecbe1d1a
2 changed files with 3 additions and 10 deletions

View File

@ -17,7 +17,6 @@ PROJECT_DIR="${HOME}/gissmo_project"
POSTGRES_VERSION="9.5" POSTGRES_VERSION="9.5"
POSTGRES_DOCKER_NAME="gissmo_db" POSTGRES_DOCKER_NAME="gissmo_db"
DB_DIR="/dbdata" DB_DIR="/dbdata"
DB_VOLUME_NAME="dbdata"
GIT_BRANCH="v1.7" GIT_BRANCH="v1.7"
GISSMO_VERSION="1.7" GISSMO_VERSION="1.7"
# GISSMO_DOCKER_NAME="gissmo" # GISSMO_DOCKER_NAME="gissmo"

View File

@ -84,8 +84,7 @@ show_help() {
echo -e " Where ${green}COMMAND${reset} is one of:" echo -e " Where ${green}COMMAND${reset} is one of:"
echo -e " - backup Create a compressed postgreSQL database dump echo -e " - backup Create a compressed postgreSQL database dump
in current directory" in current directory"
echo -e " - create Create postgreSQL database volume and echo -e " - create Create postgreSQL Docker container"
postgreSQL Docker container"
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME
for Gissmo Docker container and launch it in for Gissmo Docker container and launch it in
'development' mode" 'development' mode"
@ -162,10 +161,6 @@ test_create() {
if test -z "$DB_DIR"; then if test -z "$DB_DIR"; then
error_and_quit "No database directory given (DB_DIR in config file)." error_and_quit "No database directory given (DB_DIR in config file)."
fi fi
if test -z "$DB_VOLUME_NAME"; then
error_and_quit "No database volume name given (DB_VOLUME_NAME in
config file)."
fi
if test -z "$POSTGRES_VERSION"; then if test -z "$POSTGRES_VERSION"; then
error_and_quit "No postgres version given (POSTGRES_VERSION in error_and_quit "No postgres version given (POSTGRES_VERSION in
config file)." config file)."
@ -179,8 +174,7 @@ config file)."
create() { create() {
test_create test_create
init init
$docker_cmd create -v "${DB_DIR}:/var/lib/postgresql/data" --name "${DB_VOLUME_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Initial database 'docker create' failed." $docker_cmd run -d -P -v "${DB_DIR}:/var/lib/postgresql/data" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
$docker_cmd run -d -P --volumes-from "${DB_VOLUME_NAME}" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
} }
dev() { dev() {
@ -277,7 +271,7 @@ restore() {
test_restore test_restore
$docker_cmd stop ${POSTGRES_DOCKER_NAME} && $docker_cmd rm ${POSTGRES_DOCKER_NAME} || error_and_quit "Failed to stop and delete postgreSQL Docker container: ${POSTGRES_DOCKER_NAME}" $docker_cmd stop ${POSTGRES_DOCKER_NAME} && $docker_cmd rm ${POSTGRES_DOCKER_NAME} || error_and_quit "Failed to stop and delete postgreSQL Docker container: ${POSTGRES_DOCKER_NAME}"
sudo rm -rf ${DB_DIR} || error_and_quit "Failed to delete this directory: ${DB_DIR}" sudo rm -rf ${DB_DIR} || error_and_quit "Failed to delete this directory: ${DB_DIR}"
$docker_cmd run -d -P --volumes-from "${DB_VOLUME_NAME}" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed." $docker_cmd run -d -P -v "${DB_DIR}:/var/lib/postgresql/data" --name "${POSTGRES_DOCKER_NAME}" "postgres:${POSTGRES_VERSION}" || error_and_quit "Launching database docker container failed."
sleep 6 # to wait about docker container runs totally sleep 6 # to wait about docker container runs totally
RESTORE_COMMAND="$docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -v ${DUMP_DIR}:/backup -e PGHOST=`$docker_cmd inspect -f \"{{ .NetworkSettings.IPAddress }}\" ${POSTGRES_DOCKER_NAME}` -e PGUSER=postgres postgres:${POSTGRES_VERSION} pg_restore -d postgres /backup/${DUMP_FILE}" RESTORE_COMMAND="$docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -v ${DUMP_DIR}:/backup -e PGHOST=`$docker_cmd inspect -f \"{{ .NetworkSettings.IPAddress }}\" ${POSTGRES_DOCKER_NAME}` -e PGUSER=postgres postgres:${POSTGRES_VERSION} pg_restore -d postgres /backup/${DUMP_FILE}"
exec $RESTORE_COMMAND || error_and_quit "Failed to launch this command: ${CMD}" exec $RESTORE_COMMAND || error_and_quit "Failed to launch this command: ${CMD}"