Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

aws-ecr-push-image time out

Mikael Landau April 3, 2023

Trying to get the ECR push pipe to work but we seem to be facing an issue. 

 

The following does work: 

- docker build -t open-api .

- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com

- docker tag open-api:latest $AWS_ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/open-api:${BITBUCKET_COMMIT:0:7}-$(date +"%d%m%Y-%H%M%S")

- docker push $AWS_ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/open-api:${BITBUCKET_COMMIT:0:7}-$(date +"%d%m%Y-%H%M%S")
But the following does not:
- docker build -t open-api .

- pipe: atlassian/aws-ecr-push-image:2.0.0

variables:

IMAGE_NAME: open-api

DEBUG: 'true'

TAGS: ${BITBUCKET_COMMIT:0:7}-$(date +"%d%m%Y-%H%M%S")

From looking at the py script is seems like the docker login function is hanging. We can't understand why as is logs on fine when we used the aws sdk. 

Error message: 

 

INFO: Using default authentication with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
DEBUG: Starting new HTTPS connection (1): bitbucket.org:443
DEBUG: https://bitbucket.org:443 "GET /bitbucketpipelines/official-pipes/raw/master/pipes.prod.json HTTP/1.1" 200 None
INFO: Executing the aws-ecr-push-image pipe...
DEBUG: Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
DEBUG: No config file found
DEBUG: Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
DEBUG: No config file found
DEBUG: Starting new HTTP connection (1): host.docker.internal:2375
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 398, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/local/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0x7f03b0595780>, 'Connection to host.docker.internal timed out. (connect timeout=60)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='host.docker.internal', port=2375): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f03b0595780>, 'Connection to host.docker.internal timed out. (connect timeout=60)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/docker/api/client.py", line 214, in _retrieve_server_version
return self.version(api_version=False)["ApiVersion"]
File "/usr/local/lib/python3.10/site-packages/docker/api/daemon.py", line 181, in version
return self._result(self._get(url), json=True)
File "/usr/local/lib/python3.10/site-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/docker/api/client.py", line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 553, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='host.docker.internal', port=2375): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f03b0595780>, 'Connection to host.docker.internal timed out. (connect timeout=60)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/pipe.py", line 273, in <module>
pipe.run()
File "/pipe.py", line 242, in run
docker_client = self.get_docker_client()
File "/pipe.py", line 166, in get_docker_client
self.docker_client = docker.from_env()
File "/usr/local/lib/python3.10/site-packages/docker/client.py", line 96, in from_env
return cls(
File "/usr/local/lib/python3.10/site-packages/docker/client.py", line 45, in __init__
self.api = APIClient(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/docker/api/client.py", line 197, in __init__
self._version = self._retrieve_server_version()
File "/usr/local/lib/python3.10/site-packages/docker/api/client.py", line 221, in _retrieve_server_version
raise DockerException(
docker.errors.DockerException: Error while fetching server API version: HTTPConnectionPool(host='host.docker.internal', port=2375): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f03b0595780>, 'Connection to host.docker.internal timed out. (connect timeout=60)'))

3 answers

1 vote
Jiwon Jeon May 3, 2023

@Oleksandr Kyrdan

I'm also facing this issue, even though there's enough environment variables that pipe requires.

 

script:
- source shared.env
- gradle bootBuildImage --imageName=${BITBUCKET_REPO_SLUG}:${TAG_NAME}
- pipe: atlassian/aws-ecr-push-image:2.0.0
   variables:
       AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
       AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
       AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
       IMAGE_NAME: $BITBUCKET_REPO_SLUG
       TAGS: $TAG_NAME
artifacts:
- shared.env
1 vote
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 7, 2023

Hi @Mikael Landau 

Thank you for your question!

In the example you provided, 

- docker build -t open-api .

- pipe: atlassian/aws-ecr-push-image:2.0.0

variables:

IMAGE_NAME: open-api

DEBUG: 'true'

TAGS: ${BITBUCKET_COMMIT:0:7}-$(date +"%d%m%Y-%H%M%S")

make sure you tag docker image with the tag 

open-api:${BITBUCKET_COMMIT:0:7}-$(date +"%d%m%Y-%H%M%S") 

before you use the pipe.

 

Best regards,
Oleksandr Kyrdan

0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 3, 2023

@Mikael Landau 

Try using the following login command:

- aws ecr get-login-password --region $AWS_DEFAULT_REGION | 
docker login --username AWS --password-stdin
$AWS_ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/open-api

 Note the repo-name at the end of the ecr url.

Mikael Landau April 3, 2023

This command works. It's when I do the same thing with the pipe that it does not. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events