diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 3a7159d9e4..73ab0d9c02 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -451,33 +451,28 @@ start() { DOCKERCHECK=`docker inspect --type container ${DOCKERNAME} 2>/dev/null` if [ "$?" -eq "0" ]; then - {%- if docker_container_name == "database" and sonic_asic_platform == "vs" %} - echo "Removing existing ${DOCKERNAME} container" - docker rm -f ${DOCKERNAME} + {%- if docker_container_name == "database" %} + DOCKERMOUNT="" {%- else %} + DOCKERMOUNT=`getMountPoint "$DOCKERCHECK"` + {%- endif %} + if [ x"$DOCKERMOUNT" == x"$MOUNTPATH" ]; then + CONTAINER_EXISTS="yes" + preStartAction {%- if docker_container_name == "database" %} - DOCKERMOUNT="" + echo "Starting existing ${DOCKERNAME} container" + docker start ${DOCKERNAME} {%- else %} - DOCKERMOUNT=`getMountPoint "$DOCKERCHECK"` + echo "Starting existing ${DOCKERNAME} container with HWSKU $HWSKU" + /usr/local/bin/container start ${DOCKERNAME} {%- endif %} - if [ x"$DOCKERMOUNT" == x"$MOUNTPATH" ]; then - CONTAINER_EXISTS="yes" - preStartAction - {%- if docker_container_name == "database" %} - echo "Starting existing ${DOCKERNAME} container" - docker start ${DOCKERNAME} - {%- else %} - echo "Starting existing ${DOCKERNAME} container with HWSKU $HWSKU" - /usr/local/bin/container start ${DOCKERNAME} - {%- endif %} - postStartAction - exit $? - fi + postStartAction + exit $? + fi - # docker created with a different HWSKU, remove and recreate - echo "Removing obsolete ${DOCKERNAME} container with HWSKU $DOCKERMOUNT" - docker rm -f ${DOCKERNAME} - {%- endif %} + # docker created with a different HWSKU, remove and recreate + echo "Removing obsolete ${DOCKERNAME} container with HWSKU $DOCKERMOUNT" + docker rm -f ${DOCKERNAME} fi {%- if docker_container_name == "database" %}