Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions setup-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare -r VERBOSE_MIN="${VERBOSE_ERROR}"
# Arguments -----------------------------------------------------------------------------------------------------------
#

ENV_VARS=""
CONTAINER_NAME=""
IMAGE_ID=""
LINK_DIR=""
Expand Down Expand Up @@ -96,6 +97,7 @@ function show_help_and_exit() {
echo " -n <container_name> set the name of the Docker container"
echo
echo "Other options:"
echo " -e <VAR=value> set environment variable inside the container (can be used multiple times)"
echo " -i <image_id> specify Docker image to use. This can be an image ID (hashed value) or an image name."
echo " If no value is provided, defaults to the following images in the specified order:"
echo " 1. The local image named \"docker-sonic-mgmt\""
Expand Down Expand Up @@ -298,7 +300,7 @@ EOF
function start_local_container() {
log_info "creating a container: ${CONTAINER_NAME} ..."

eval "docker run -d -t ${PUBLISH_PORTS} -h ${CONTAINER_NAME} \
eval "docker run -d -t ${PUBLISH_PORTS} ${ENV_VARS} -h ${CONTAINER_NAME} \
-v \"$(dirname "${SCRIPT_DIR}"):${LINK_DIR}:rslave\" ${MOUNT_POINTS} \
--name \"${CONTAINER_NAME}\" \"${LOCAL_IMAGE}\" /bin/bash ${SILENT_HOOK}" || \
exit_failure "failed to start a container: ${CONTAINER_NAME}"
Expand Down Expand Up @@ -339,11 +341,14 @@ if [[ $# -eq 0 ]]; then
show_help_and_exit "${EXIT_SUCCESS}"
fi

while getopts "n:i:d:m:p:fvxh" opt; do
while getopts "e:n:i:d:m:p:fvxh" opt; do
case "${opt}" in
n )
CONTAINER_NAME="${OPTARG}"
;;
e )
ENV_VARS+=" -e ${OPTARG}"
;;
i )
IMAGE_ID="${OPTARG}"
;;
Expand Down
Loading