Docker push launched within Sagemaker notebook fails

0

My question is similar to this post, except I'm running a script to extend a pre-built container in a Sagemaker notebook, as per the tutorial here.

%cd ~/SageMaker/docker_test_folder

! aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin myawsacct.dkr.ecr.us-east-1.amazonaws.com
%%sh

# Specify an algorithm name
algorithm_name=container-testing11

account=$(aws sts get-caller-identity --query Account --output text)

# Get the region defined in the current configuration (default to us-west-2 if none defined)
region=$(aws configure get region)

fullname="${account}.dkr.ecr.${region}.amazonaws.com/${algorithm_name}:latest"

# If the repository doesn't exist in ECR, create it.

aws ecr describe-repositories --repository-names "${algorithm_name}" > /dev/null 2>&1
if [ $? -ne 0 ]
then
aws ecr create-repository --repository-name "${algorithm_name}" > /dev/null
fi

# Log into Docker
aws ecr get-login-password --region ${region}|docker login --username AWS --password-stdin ${fullname}

# Build the docker image locally with the image name and then push it to ECR
# with the full name.

docker build -t ${algorithm_name} .
docker tag ${algorithm_name} ${fullname}

echo $fullname

docker push ${fullname}

My dockerfile in the docker_test_folder directory:

# SageMaker PyTorch image
FROM myawsacct.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:2.0.0-cpu-py310

ENV PATH="/opt/ml/code:${PATH}"

# this environment variable is used by the SageMaker PyTorch container to determine our user code directory.
ENV SAGEMAKER_SUBMIT_DIRECTORY /opt/ml/code

COPY serialize.py /opt/ml/code/serialize.py

ENV SAGEMAKER_PROGRAM serialize.py

I get the message below:

611ca701782a: Preparing
418e5245c533: Preparing
eb7d2ad7c2f3: Preparing
0901a516192c: Preparing
37c972223042: Preparing
57ceaf08a98c: Preparing
3faad9ce30a9: Preparing
54cc27394bf8: Preparing
f73926fcbab5: Preparing
ae0068631e8f: Preparing
92d3c169bb1d: Preparing
0959b1e32861: Preparing
0b688b87ab65: Preparing
1c4fb5c6af64: Preparing
f5043d0af726: Preparing
be3ce9800546: Preparing
d42e2cf3b741: Preparing
02269fc6bf26: Preparing
07454ecc5eac: Preparing
4e4ad728d71c: Preparing
a05747b8386d: Preparing
42c99d65f9fa: Preparing
1ba09563450c: Preparing
1b0ef6b92bc1: Preparing
771656b3006f: Preparing
6f37ca73c74f: Preparing
57ceaf08a98c: Waiting
3faad9ce30a9: Waiting
54cc27394bf8: Waiting
f73926fcbab5: Waiting
ae0068631e8f: Waiting
92d3c169bb1d: Waiting
0959b1e32861: Waiting
0b688b87ab65: Waiting
1c4fb5c6af64: Waiting
f5043d0af726: Waiting
be3ce9800546: Waiting
d42e2cf3b741: Waiting
02269fc6bf26: Waiting
07454ecc5eac: Waiting
4e4ad728d71c: Waiting
a05747b8386d: Waiting
42c99d65f9fa: Waiting
1ba09563450c: Waiting
1b0ef6b92bc1: Waiting
771656b3006f: Waiting
6f37ca73c74f: Waiting
611ca701782a: Retrying in 5 seconds
0901a516192c: Retrying in 5 seconds
eb7d2ad7c2f3: Retrying in 5 seconds

and then the error:

CalledProcessError: Command 'b'\n# Specify an algorithm name\nalgorithm_name=container-testing10\n\naccount=$(aws sts get-caller-identity --query Account --output text)\n\n# Get the region defined in the current configuration (default to us-west-2 if none defined)\nregion=$(aws configure get region)\n\nfullname="${account}.dkr.ecr.${region}.amazonaws.com/${algorithm_name}:latest"\n\n# If the repository doesn\'t exist in ECR, create it.\n\naws ecr describe-repositories --repository-names "${algorithm_name}" > /dev/null 2>&1\nif [ $? -ne 0 ]\nthen\naws ecr create-repository --repository-name "${algorithm_name}" > /dev/null\nfi\n\n# Log into Docker\naws ecr get-login-password --region ${region}|docker login --username AWS --password-stdin ${fullname}\n\n# Build the docker image locally with the image name and then push it to ECR\n# with the full name.\n\ndocker build -t ${algorithm_name} .\ndocker tag ${algorithm_name} ${fullname}\n\necho $fullname\n\ndocker push ${fullname}\n'' returned non-zero exit status 1.

The Docker tag command runs fine.

asked 2 months ago64 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions