You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by uc...@apache.org on 2017/03/15 13:13:37 UTC

[1/2] flink git commit: [FLINK-5635] [docker] Improvements for Docker on Flink experience

Repository: flink
Updated Branches:
  refs/heads/master 31ab4b247 -> a3627f201


[FLINK-5635] [docker] Improvements for Docker on Flink experience

Modifying Dockerfile to build from local flink-dist as well as release URLs.
Logging to stdout.
Adding scripts to deploy seamlessly on Docker Swarm.
Updating Docker Compose scripts to work correctly.
Parameterizing things so these Docker scripts are more generally useful.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/227478bc
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/227478bc
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/227478bc

Branch: refs/heads/master
Commit: 227478bc713aa399b00a0285b86a8778dc5d8b05
Parents: 31ab4b2
Author: Jamie Grier <ja...@gmail.com>
Authored: Fri Jan 20 16:12:17 2017 -0800
Committer: Ufuk Celebi <uc...@apache.org>
Committed: Wed Mar 15 14:12:48 2017 +0100

----------------------------------------------------------------------
 flink-contrib/docker-flink/Dockerfile           | 24 +++---
 flink-contrib/docker-flink/build.sh             | 80 +++++++++++++++++++-
 .../docker-flink/create-docker-swarm-service.sh | 54 +++++++++++++
 flink-contrib/docker-flink/docker-compose.yml   | 15 ++--
 flink-contrib/docker-flink/log4j.properties     | 47 ++++++++++++
 .../docker-flink/remove-docker-swarm-service.sh | 43 +++++++++++
 6 files changed, 242 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/227478bc/flink-contrib/docker-flink/Dockerfile
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/Dockerfile b/flink-contrib/docker-flink/Dockerfile
index 133df34..943adcb 100644
--- a/flink-contrib/docker-flink/Dockerfile
+++ b/flink-contrib/docker-flink/Dockerfile
@@ -21,11 +21,6 @@ FROM java:8-jre-alpine
 # Install requirements
 RUN apk add --no-cache bash snappy
 
-# Configure Flink version
-ARG FLINK_VERSION=1.1.3
-ARG HADOOP_VERSION=27
-ARG SCALA_VERSION=2.11
-
 # Flink environment variables
 ENV FLINK_INSTALL_PATH=/opt
 ENV FLINK_HOME $FLINK_INSTALL_PATH/flink
@@ -36,22 +31,25 @@ ENV PATH $PATH:$FLINK_HOME/bin
 EXPOSE 8081
 EXPOSE 6123
 
+# flink-dist can point to a directory, a tarball on the local system, or a url to a tarball
+ARG flink_dist=NOT_SET
+
 # Install build dependencies and flink
+ADD $flink_dist $FLINK_INSTALL_PATH
 RUN set -x && \
   mkdir -p $FLINK_INSTALL_PATH && \
-  apk --update add --virtual build-dependencies curl && \
-  curl -s $(curl -s https://www.apache.org/dyn/closer.cgi\?preferred\=true)flink/flink-${FLINK_VERSION}/flink-${FLINK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala_${SCALA_VERSION}.tgz | \
-  tar xvz -C $FLINK_INSTALL_PATH && \
-  ln -s $FLINK_INSTALL_PATH/flink-$FLINK_VERSION $FLINK_HOME && \
+  ln -s $FLINK_INSTALL_PATH/flink-* $FLINK_HOME && \
   addgroup -S flink && adduser -D -S -H -G flink -h $FLINK_HOME flink && \
-  chown -R flink:flink $FLINK_INSTALL_PATH/flink-$FLINK_VERSION && \
+  chown -R flink:flink $FLINK_INSTALL_PATH/flink-* && \
   chown -h flink:flink $FLINK_HOME && \
-  sed -i -e "s/echo \$mypid >> \$pid/echo \$mypid >> \$pid \&\& wait/g" $FLINK_HOME/bin/flink-daemon.sh && \
-  apk del build-dependencies && \
-  rm -rf /var/cache/apk/*
+  sed -i -e "s/echo \$mypid >> \$pid/echo \$mypid >> \$pid \&\& wait/g" $FLINK_HOME/bin/flink-daemon.sh
 
 # Configure container
 USER flink
 ADD docker-entrypoint.sh $FLINK_HOME/bin/
+
+# Overwrite default logging settings.  This will additionally log to stdout so we can use 'docker logs'
+ADD log4j.properties $FLINK_HOME/conf/
+
 ENTRYPOINT ["docker-entrypoint.sh"]
 CMD ["sh", "-c"]

http://git-wip-us.apache.org/repos/asf/flink/blob/227478bc/flink-contrib/docker-flink/build.sh
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/build.sh b/flink-contrib/docker-flink/build.sh
index 92a61ad..c1003ad 100755
--- a/flink-contrib/docker-flink/build.sh
+++ b/flink-contrib/docker-flink/build.sh
@@ -18,4 +18,82 @@
 # limitations under the License.
 ################################################################################
 
-docker build -t "flink" .
+usage() {
+  cat <<HERE
+Usage:
+  build.sh --from-local-dist [--image-name <image>]
+  build.sh --from-release --flink-version <x.x.x> --hadoop-version <x.x> --scala-version <x.xx> [--image-name <image>]
+  build.sh --help
+
+  If the --image-name flag is not used the built image name will be 'flink'.
+HERE
+  exit 1
+}
+
+while [[ $# -ge 1 ]]
+do
+key="$1"
+  case $key in
+    --from-local-dist)
+    FROM_LOCAL="true"
+    ;;
+    --from-release)
+    FROM_RELEASE="true"
+    ;;
+    --image-name)
+    IMAGE_NAME="$2"
+    shift
+    ;;
+    --flink-version)
+    FLINK_VERSION="$2"
+    shift
+    ;;
+    --hadoop-version)
+    HADOOP_VERSION="$(echo "$2" | sed 's/\.//')"
+    shift
+    ;;
+    --scala-version)
+    SCALA_VERSION="$2"
+    shift
+    ;;
+    --help)
+    usage
+    ;;
+    *)
+    # unknown option
+    ;;
+  esac
+  shift
+done
+
+IMAGE_NAME=${IMAGE_NAME:-flink}
+
+TMPDIR=_TMP_
+mkdir -p "${TMPDIR}"
+
+if [ -n "${FROM_RELEASE}" ]; then
+
+  [[ -n "${FLINK_VERSION}" ]] && [[ -n "${HADOOP_VERSION}" ]] && [[ -n "${SCALA_VERSION}" ]] || usage
+
+  FLINK_BASE_URL="$(curl -s https://www.apache.org/dyn/closer.cgi\?preferred\=true)flink/flink-${FLINK_VERSION}/"
+  FLINK_DIST_FILE_NAME="flink-${FLINK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala_${SCALA_VERSION}.tgz"
+  CURL_OUTPUT="${TMPDIR}/${FLINK_DIST_FILE_NAME}"
+
+  echo "Downloading ${FLINK_DIST_FILE_NAME} from ${FLINK_BASE_URL}"
+  curl -s ${FLINK_BASE_URL}${FLINK_DIST_FILE_NAME} --output ${CURL_OUTPUT}
+
+  FLINK_DIST="${CURL_OUTPUT}"
+
+elif [ -n "${FROM_LOCAL}" ]; then
+
+    DIST_DIR="../../flink-dist/target/flink-*-bin"
+    FLINK_DIST="${TMPDIR}/flink.tgz"
+    echo "Using flink dist: ${DIST_DIR}"
+    tar -C ${DIST_DIR} -cvzf "${FLINK_DIST}" .
+else
+  usage
+fi
+
+docker build --build-arg flink_dist="${FLINK_DIST}" -t "${IMAGE_NAME}" .
+
+rm -rf "${TMPDIR}"

http://git-wip-us.apache.org/repos/asf/flink/blob/227478bc/flink-contrib/docker-flink/create-docker-swarm-service.sh
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/create-docker-swarm-service.sh b/flink-contrib/docker-flink/create-docker-swarm-service.sh
new file mode 100755
index 0000000..4393a70
--- /dev/null
+++ b/flink-contrib/docker-flink/create-docker-swarm-service.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+usage() {
+  cat <<HERE
+Usage:
+  create-docker-swarm-service.sh [--image-name <image>] <service-name> <service-port>
+
+  If the --image-name flag is not used the service will use the 'flink' image.
+HERE
+  exit 1
+}
+
+if [ "$1" == "--image-name" ]; then
+  IMAGE_NAME="$2"
+  shift; shift
+else
+  IMAGE_NAME=flink
+fi
+
+[[ $# -ne 2 ]] && usage
+
+SERVICE_BASE_NAME="$1"
+SERVICE_PORT="${2}"
+JOB_MANAGER_NAME=${SERVICE_BASE_NAME}-jobmanager
+TASK_MANAGER_NAME=${SERVICE_BASE_NAME}-taskmanager
+JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_NAME}
+OVERLAY_NETWORK_NAME=${SERVICE_BASE_NAME}
+
+# Create overlay network
+docker network create -d overlay ${OVERLAY_NETWORK_NAME}
+
+# Create the jobmanager service
+docker service create --name ${JOB_MANAGER_NAME} --env JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS} -p ${SERVICE_PORT}:8081 --network ${OVERLAY_NETWORK_NAME} ${IMAGE_NAME} jobmanager
+
+# Create the taskmanger service (scale this out as needed)
+docker service create --name ${TASK_MANAGER_NAME} --env JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS} --network ${OVERLAY_NETWORK_NAME} ${IMAGE_NAME} taskmanager

http://git-wip-us.apache.org/repos/asf/flink/blob/227478bc/flink-contrib/docker-flink/docker-compose.yml
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/docker-compose.yml b/flink-contrib/docker-flink/docker-compose.yml
index 6a13353..702d318 100644
--- a/flink-contrib/docker-flink/docker-compose.yml
+++ b/flink-contrib/docker-flink/docker-compose.yml
@@ -16,21 +16,22 @@
 # limitations under the License.
 ################################################################################
 
-version: "2"
+# Set the FLINK_DOCKER_IMAGE_NAME environment variable to override the image name to use
+
+version: "2.1"
 services:
   jobmanager:
-    image: flink
-    container_name: "jobmanager"
+    image: ${FLINK_DOCKER_IMAGE_NAME:-flink}
     expose:
       - "6123"
     ports:
-      - "48081:8081"
+      - "8081:8081"
     command: jobmanager
     environment:
-      - JOB_MANAGER_RPC_ADDRESS="jobmanager"
+      - JOB_MANAGER_RPC_ADDRESS=jobmanager
 
   taskmanager:
-    image: flink
+    image: ${FLINK_DOCKER_IMAGE_NAME:-flink}
     expose:
       - "6121"
       - "6122"
@@ -40,4 +41,4 @@ services:
     links:
       - "jobmanager:jobmanager"
     environment:
-      - JOB_MANAGER_RPC_ADDRESS="jobmanager"
+      - JOB_MANAGER_RPC_ADDRESS=jobmanager

http://git-wip-us.apache.org/repos/asf/flink/blob/227478bc/flink-contrib/docker-flink/log4j.properties
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/log4j.properties b/flink-contrib/docker-flink/log4j.properties
new file mode 100644
index 0000000..2bd1210
--- /dev/null
+++ b/flink-contrib/docker-flink/log4j.properties
@@ -0,0 +1,47 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+# This affects logging for both user code and Flink
+log4j.rootLogger=INFO, file, console
+
+# Uncomment this if you want to _only_ change Flink's logging
+#log4j.logger.org.apache.flink=INFO
+
+# The following lines keep the log level of common libraries/connectors on
+# log level INFO. The root logger does not override this. You have to manually
+# change the log levels here.
+log4j.logger.akka=INFO
+log4j.logger.org.apache.kafka=INFO
+log4j.logger.org.apache.hadoop=INFO
+log4j.logger.org.apache.zookeeper=INFO
+
+# Log all infos in the given file
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.file=${log.file}
+log4j.appender.file.append=false
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
+
+# Log to stdout as well
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.target=System.err
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
+
+# Suppress the irrelevant (wrong) warnings from the Netty channel handler
+log4j.logger.org.jboss.netty.channel.DefaultChannelPipeline=ERROR, file, console

http://git-wip-us.apache.org/repos/asf/flink/blob/227478bc/flink-contrib/docker-flink/remove-docker-swarm-service.sh
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/remove-docker-swarm-service.sh b/flink-contrib/docker-flink/remove-docker-swarm-service.sh
new file mode 100755
index 0000000..7cdc1c7
--- /dev/null
+++ b/flink-contrib/docker-flink/remove-docker-swarm-service.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+usage() {
+  cat <<HERE
+Usage:
+  remove-docker-swarm-service.sh <service-name> 
+HERE
+  exit 1
+}
+
+[[ $# -ne 1 ]] && usage
+
+SERVICE_BASE_NAME="$1"
+JOB_MANAGER_NAME=${SERVICE_BASE_NAME}-jobmanager
+TASK_MANAGER_NAME=${SERVICE_BASE_NAME}-taskmanager
+OVERLAY_NETWORK_NAME=${SERVICE_BASE_NAME}
+
+# Remove taskmanager service
+docker service rm ${TASK_MANAGER_NAME}
+
+# Remove jobmanager service
+docker service rm ${JOB_MANAGER_NAME}
+
+# Remove overlay network
+docker network rm ${OVERLAY_NETWORK_NAME}


[2/2] flink git commit: [FLINK-5635] [docker] Use start-foreground in Docker entrypoint

Posted by uc...@apache.org.
[FLINK-5635] [docker] Use start-foreground in Docker entrypoint

docker-entrypoint.sh should error on invalid args

Improve docker build.sh cleanup

Dockerfile improvements per review

Remove unnecessary Dockerfile build steps

Now that docker-entrypoint.sh uses 'start-foreground', munging
flink-daemon.sh and overwriting the log4j config are not longer
necessary.

Improve Dockerfile and docker-entrypoint.sh

Clean up Dockerfile and improve docker-entrypoint.sh to support '--help'
and pass through non-(jobmanager|taskmanager) commands.

This closes #3205.
This closes #3494.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/a3627f20
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/a3627f20
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/a3627f20

Branch: refs/heads/master
Commit: a3627f201ba25783cdd445921ef23b7dae5df73d
Parents: 227478b
Author: Patrick Lucas <me...@patricklucas.com>
Authored: Tue Mar 7 16:26:12 2017 +0100
Committer: Ufuk Celebi <uc...@apache.org>
Committed: Wed Mar 15 14:12:49 2017 +0100

----------------------------------------------------------------------
 flink-contrib/docker-flink/Dockerfile           | 24 +++-------
 flink-contrib/docker-flink/build.sh             | 21 ++++++---
 flink-contrib/docker-flink/docker-entrypoint.sh | 23 +++++-----
 flink-contrib/docker-flink/log4j.properties     | 47 --------------------
 4 files changed, 32 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/a3627f20/flink-contrib/docker-flink/Dockerfile
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/Dockerfile b/flink-contrib/docker-flink/Dockerfile
index 943adcb..46db36c 100644
--- a/flink-contrib/docker-flink/Dockerfile
+++ b/flink-contrib/docker-flink/Dockerfile
@@ -26,30 +26,20 @@ ENV FLINK_INSTALL_PATH=/opt
 ENV FLINK_HOME $FLINK_INSTALL_PATH/flink
 ENV PATH $PATH:$FLINK_HOME/bin
 
-# These can be mapped from the host to the container using
-# $ docker run -t flink -p 8081:8081 -p 6123:6123 jobmanager
-EXPOSE 8081
-EXPOSE 6123
-
-# flink-dist can point to a directory, a tarball on the local system, or a url to a tarball
+# flink-dist can point to a directory or a tarball on the local system
 ARG flink_dist=NOT_SET
 
 # Install build dependencies and flink
 ADD $flink_dist $FLINK_INSTALL_PATH
 RUN set -x && \
-  mkdir -p $FLINK_INSTALL_PATH && \
   ln -s $FLINK_INSTALL_PATH/flink-* $FLINK_HOME && \
   addgroup -S flink && adduser -D -S -H -G flink -h $FLINK_HOME flink && \
   chown -R flink:flink $FLINK_INSTALL_PATH/flink-* && \
-  chown -h flink:flink $FLINK_HOME && \
-  sed -i -e "s/echo \$mypid >> \$pid/echo \$mypid >> \$pid \&\& wait/g" $FLINK_HOME/bin/flink-daemon.sh
-
-# Configure container
-USER flink
-ADD docker-entrypoint.sh $FLINK_HOME/bin/
+  chown -h flink:flink $FLINK_HOME
 
-# Overwrite default logging settings.  This will additionally log to stdout so we can use 'docker logs'
-ADD log4j.properties $FLINK_HOME/conf/
+COPY docker-entrypoint.sh /
 
-ENTRYPOINT ["docker-entrypoint.sh"]
-CMD ["sh", "-c"]
+USER flink
+EXPOSE 8081 6123
+ENTRYPOINT ["/docker-entrypoint.sh"]
+CMD ["--help"]

http://git-wip-us.apache.org/repos/asf/flink/blob/a3627f20/flink-contrib/docker-flink/build.sh
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/build.sh b/flink-contrib/docker-flink/build.sh
index c1003ad..26557a2 100755
--- a/flink-contrib/docker-flink/build.sh
+++ b/flink-contrib/docker-flink/build.sh
@@ -68,7 +68,15 @@ done
 
 IMAGE_NAME=${IMAGE_NAME:-flink}
 
+# TMPDIR must be contained within the working directory so it is part of the
+# Docker context. (i.e. it can't be mktemp'd in /tmp)
 TMPDIR=_TMP_
+
+cleanup() {
+    rm -rf "${TMPDIR}"
+}
+trap cleanup EXIT
+
 mkdir -p "${TMPDIR}"
 
 if [ -n "${FROM_RELEASE}" ]; then
@@ -86,14 +94,15 @@ if [ -n "${FROM_RELEASE}" ]; then
 
 elif [ -n "${FROM_LOCAL}" ]; then
 
-    DIST_DIR="../../flink-dist/target/flink-*-bin"
-    FLINK_DIST="${TMPDIR}/flink.tgz"
-    echo "Using flink dist: ${DIST_DIR}"
-    tar -C ${DIST_DIR} -cvzf "${FLINK_DIST}" .
+  DIST_DIR="../../flink-dist/target/flink-*-bin"
+  FLINK_DIST="${TMPDIR}/flink.tgz"
+  echo "Using flink dist: ${DIST_DIR}"
+  tar -C ${DIST_DIR} -cvzf "${FLINK_DIST}" .
+
 else
+
   usage
+
 fi
 
 docker build --build-arg flink_dist="${FLINK_DIST}" -t "${IMAGE_NAME}" .
-
-rm -rf "${TMPDIR}"

http://git-wip-us.apache.org/repos/asf/flink/blob/a3627f20/flink-contrib/docker-flink/docker-entrypoint.sh
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/docker-entrypoint.sh b/flink-contrib/docker-flink/docker-entrypoint.sh
index db567cc..1fc13cf 100755
--- a/flink-contrib/docker-flink/docker-entrypoint.sh
+++ b/flink-contrib/docker-flink/docker-entrypoint.sh
@@ -19,29 +19,26 @@
 ################################################################################
 
 ### If unspecified, the hostname of the container is taken as the JobManager address
-JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS:-`hostname -f`}
+JOB_MANAGER_RPC_ADDRESS=${JOB_MANAGER_RPC_ADDRESS:-$(hostname -f)}
 ###
 
-if [ "$1" == "jobmanager" ]; then
+if [ "$1" == "--help" -o "$1" == "-h" ]; then
+    echo "Usage: $(basename $0) (jobmanager|taskmanager)"
+    exit 0
+elif [ "$1" == "jobmanager" ]; then
     echo "Starting Job Manager"
     sed -i -e "s/jobmanager.rpc.address: localhost/jobmanager.rpc.address: ${JOB_MANAGER_RPC_ADDRESS}/g" $FLINK_HOME/conf/flink-conf.yaml
 
     echo "config file: " && grep '^[^\n#]' $FLINK_HOME/conf/flink-conf.yaml
-    $FLINK_HOME/bin/jobmanager.sh start cluster
-
-  # prevent script to exit
-  tail -f /dev/null
+    exec $FLINK_HOME/bin/jobmanager.sh start-foreground cluster
 elif [ "$1" == "taskmanager" ]; then
 
     sed -i -e "s/jobmanager.rpc.address: localhost/jobmanager.rpc.address: ${JOB_MANAGER_RPC_ADDRESS}/g" $FLINK_HOME/conf/flink-conf.yaml
-    sed -i -e "s/taskmanager.numberOfTaskSlots: 1/taskmanager.numberOfTaskSlots: `grep -c ^processor /proc/cpuinfo`/g" $FLINK_HOME/conf/flink-conf.yaml
+    sed -i -e "s/taskmanager.numberOfTaskSlots: 1/taskmanager.numberOfTaskSlots: $(grep -c ^processor /proc/cpuinfo)/g" $FLINK_HOME/conf/flink-conf.yaml
 
     echo "Starting Task Manager"
     echo "config file: " && grep '^[^\n#]' $FLINK_HOME/conf/flink-conf.yaml
-    $FLINK_HOME/bin/taskmanager.sh start
-
-  # prevent script to exit
-  tail -f /dev/null
-else
-    $@
+    exec $FLINK_HOME/bin/taskmanager.sh start-foreground
 fi
+
+exec "$@"

http://git-wip-us.apache.org/repos/asf/flink/blob/a3627f20/flink-contrib/docker-flink/log4j.properties
----------------------------------------------------------------------
diff --git a/flink-contrib/docker-flink/log4j.properties b/flink-contrib/docker-flink/log4j.properties
deleted file mode 100644
index 2bd1210..0000000
--- a/flink-contrib/docker-flink/log4j.properties
+++ /dev/null
@@ -1,47 +0,0 @@
-################################################################################
-#  Licensed to the Apache Software Foundation (ASF) under one
-#  or more contributor license agreements.  See the NOTICE file
-#  distributed with this work for additional information
-#  regarding copyright ownership.  The ASF licenses this file
-#  to you under the Apache License, Version 2.0 (the
-#  "License"); you may not use this file except in compliance
-#  with the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-# limitations under the License.
-################################################################################
-
-# This affects logging for both user code and Flink
-log4j.rootLogger=INFO, file, console
-
-# Uncomment this if you want to _only_ change Flink's logging
-#log4j.logger.org.apache.flink=INFO
-
-# The following lines keep the log level of common libraries/connectors on
-# log level INFO. The root logger does not override this. You have to manually
-# change the log levels here.
-log4j.logger.akka=INFO
-log4j.logger.org.apache.kafka=INFO
-log4j.logger.org.apache.hadoop=INFO
-log4j.logger.org.apache.zookeeper=INFO
-
-# Log all infos in the given file
-log4j.appender.file=org.apache.log4j.FileAppender
-log4j.appender.file.file=${log.file}
-log4j.appender.file.append=false
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
-
-# Log to stdout as well
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.target=System.err
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
-
-# Suppress the irrelevant (wrong) warnings from the Netty channel handler
-log4j.logger.org.jboss.netty.channel.DefaultChannelPipeline=ERROR, file, console