Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Cleans up docker container on sigterm and sigint
Browse files Browse the repository at this point in the history
  • Loading branch information
perdasilva committed Oct 11, 2019
1 parent daaebf8 commit 57093a4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cd/python/docker/python_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ image_name="${repository}:${main_tag}"

resources_path='cd/python/docker'

container_name=`uuidgen`

if [ ! -z "${RELEASE_DOCKERHUB_REPOSITORY}" ]; then
image_name="${RELEASE_DOCKERHUB_REPOSITORY}/${image_name}"
fi

docker_clean_up() {
docker rm -f "${container_name}"
}


# Builds runtime image
build() {
# NOTE: Ensure the correct context root is passed in when building - Dockerfile expects ./wheel_build
Expand All @@ -74,7 +81,11 @@ test() {

# Ensure the correct context root is passed in when building - Dockerfile.test expects ci directory
docker build -t "${test_image_name}" --build-arg USER_ID=`id -u` --build-arg GROUP_ID=`id -g` --build-arg BASE_IMAGE="${image_name}" -f ${resources_path}/Dockerfile.test ./ci
docker run ${runtime_param} -u `id -u`:`id -g` -v `pwd`:/mxnet "${test_image_name}" ${resources_path}/test_python_image.sh "${mxnet_variant}" "${python_cmd}"

# Trap the SIGINT and SIGTERM signals and quickly kill the container
# This avoid leaving zombie containers hanging around on the host
trap docker_clean_up SIGINT SIGTERM

This comment has been minimized.

Copy link
@marcoabreu

marcoabreu Oct 11, 2019

Contributor

Yeah please don't reinvent the wheel. We already solved all these challenges with the build.py wrapper

docker run ${runtime_param} --name "${container_name}" -u `id -u`:`id -g` -v `pwd`:/mxnet "${test_image_name}" ${resources_path}/test_python_image.sh "${mxnet_variant}" "${python_cmd}"
}

# Pushes the runtime image to the repository
Expand Down

0 comments on commit 57093a4

Please sign in to comment.