Skip to content

Commit

Permalink
Add container length check (#15758)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
To enhance error messaging for this particular edge case, as it was previously difficult to discern why the container would be created successfully, but then consistently fail to start.

How did you do it?
Adds a check to prevent containers from being created with name lengths greater than 64 characters, as these containers will not be able to start.

How did you verify/test it?
Ran the setup script, with both a valid name and an invalid name (valid is on the left, invalid is on the right):
  • Loading branch information
matthew-soulsby authored Nov 27, 2024
1 parent b829948 commit 1aa4c0e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ function parse_arguments() {
else
exit_failure "found existing container (\"docker start $EXISTING_CONTAINER_NAME\")"
fi
else
# If container name is over 64 characters, container will not be able to start due to hostname limitation
container_name_len=${#CONTAINER_NAME}
if [ "$container_name_len" -gt "64" ]; then
exit_failure "Length of supplied container name exceeds 64 characters (currently $container_name_len chars)"
fi
fi

if [[ -z "${LINK_DIR}" ]]; then
Expand Down

0 comments on commit 1aa4c0e

Please sign in to comment.