Reputation: 1548
I'm using a dynamodb docker container to run some tests in an Atlassian Bitbucket pipeline. These steps work locally with the same exact docker run
command, but for some reason I cannot connect to the db container after it starts while running in the pipeline:
image: python:3.6
pipelines:
default:
- step:
caches:
- docker
script:
- docker run -d -p 8000:8000 --name dynamodb --entrypoint java amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb -inMemory
- curl http://localhost:8000
services:
- docker
The curl command returns:
curl http://localhost:8000 % Total % Received % Xferd Average Speed
Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0
0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:-
-:-- 0curl: (56) Recv failure: Connection reset by peer
I've tried with both localhost and dynamodb as the host names with the same result. I've also posted this on the Atlassian Community, but got no answers.
Upvotes: 1
Views: 1541
Reputation: 33511
You should not start amazon/dynamodb-local
manually, you should use services instead:
definitions:
services:
dynamodb-local:
image: amazon/dynamodb-local
memory: 2048
pipelines:
default:
- step:
image: python:3.6
size: 2x
services:
- dynamodb-local
script:
- export DYNAMODB_LOCAL_URL=http://localhost:8000
- export AWS_DEFAULT_REGION=us-east-1
- export AWS_ACCESS_KEY_ID=''
- export AWS_SECRET_ACCESS_KEY=''
- aws --endpoint-url ${DYNAMODB_LOCAL_URL} dynamodb delete-table --table-name test || true
- aws --endpoint-url ${DYNAMODB_LOCAL_URL} dynamodb create-table --cli-input-json file://test.table.json
- python -m unittest test_module.TestClass
You'll probably need to double the size of container and memory as DynamoDB is pretty heavvweight (but it may work on defaults as well).
Upvotes: 5