I have a CircleCI job that first builds a Docker container image and then tests it by launching a corresponding container, and sending HTTP requests to it. However, it’s impossible to connect to the container on the published port. The connection is simply refused, and I can’t tell why. The same workflow works locally. Does anyone know why it doesn’t work to connect to a Docker container in a CircleCI job?
My CircleCI config looks like this:
version: 2
jobs:
build:
docker:
- image: aknudsen/docker-with-node-python
working_directory: ~/build
steps:
- checkout
- setup_remote_docker:
version: 17.10.0-ce
- run:
name: Build Docker image
command: |
docker build -t quay.io/socialfoodie/web:$CIRCLE_SHA1 .
docker tag quay.io/socialfoodie/web:$CIRCLE_SHA1 quay.io/socialfoodie/web:latest
- run:
name: Test
command: |
npm install
pip3 install -r requirements.txt
npm test
- deploy:
name: Push Docker image
command: |
if [ "${CIRCLE_BRANCH}" == "release" ]; then
docker login -u $QUAY_USER -p $QUAY_PASSWORD quay.io
docker push quay.io/socialfoodie/web:$CIRCLE_SHA1
docker push quay.io/socialfoodie/web:latest
fi