mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Connect to running container if -c is used
This commit is contained in:
parent
f21bffe322
commit
f01102fd34
9
setup.sh
9
setup.sh
|
@ -12,6 +12,7 @@ INFO=$(docker ps \
|
|||
IMAGE_NAME=$(echo $INFO | awk '{print $1}')
|
||||
CONTAINER_NAME=$(echo $INFO | awk '{print $2}')
|
||||
DEFAULT_CONFIG_PATH="$(pwd)/config"
|
||||
USE_CONTAINER=false
|
||||
|
||||
_update_config_path() {
|
||||
VOLUME=$(docker inspect $CONTAINER_NAME \
|
||||
|
@ -98,14 +99,21 @@ _docker_image_exists() {
|
|||
}
|
||||
|
||||
_docker_image() {
|
||||
if [ "$USE_CONTAINER" = true ]; then
|
||||
# Reuse existing container specified on command line
|
||||
docker exec -ti "$CONTAINER_NAME" "$@"
|
||||
else
|
||||
# Start temporary container with specified image
|
||||
if ! _docker_image_exists "$IMAGE_NAME"; then
|
||||
echo "Image '$IMAGE_NAME' not found. Pulling ..."
|
||||
docker pull "$IMAGE_NAME"
|
||||
fi
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
-v "$CONFIG_PATH":/tmp/docker-mailserver \
|
||||
-ti "$IMAGE_NAME" $@
|
||||
fi
|
||||
}
|
||||
|
||||
_docker_container() {
|
||||
|
@ -121,6 +129,7 @@ while getopts ":c:i:p:" OPT; do
|
|||
case $OPT in
|
||||
c)
|
||||
CONTAINER_NAME="$OPTARG"
|
||||
USE_CONTAINER=true # Container specified, connect to running instance
|
||||
;;
|
||||
i)
|
||||
IMAGE_NAME="$OPTARG"
|
||||
|
|
Loading…
Reference in a new issue