I’m trying to setup my full application stack using multiple images, to run end to end tests. My stack consists of a web front end, a backend API, as well as Redis and MySQL images. The tests are stored with the front end repo.
To bring up my stack, I need the backend API to be able to talk to the MySQL and Redis containers. I can connect to the MySQL and Redis containers from my primary container after they start, but it does not appear that the backend API can communicate with with MySQL/Redis on localhost:3306 and localhost:6379.
My config looks something like this:
version: 2
jobs:
build:
docker:
- image: <dockerhub>/my-frontend:0.1
- image: circleci/mysql:5.6.35 # Listen on 3306
- image: circleci/redis:4.0.11-alpine # Listen on 6379
- image: <dockerhub>/my-backend:0.1 # Listen on 3000
steps:
- checkout
- run:
command: |
# ... do some setup, then wait for services ....
./dockerize -wait tcp://localhost:3306 -timeout 60s # this works here, but not from the backend entrypoint
./dockerize -wait tcp://localhost:6379 -timeout 60s # this works here, but not from the backend entrypoint
./dockerize -wait tcp://localhost:3000 -timeout 60s # this never establishes a connection
# execute my tests...
# yarn test
The container for the backend has an entrypoint script which waits for both MySQL and Redis instances to come up prior to starting:
./dockerize -wait tcp://localhost:3306 -timeout 60s
./dockerize -wait tcp://localhost:6379 -timeout 60s
However, the backend never comes up in this setup, presumably because those dockerize commands never return… I’m just wondering if this should work? Or do I have to use compose when I have containers that must talk to other containers, which are not the primary container?
Note: I’ve been able to get something similar working with docker-compose and the CircleCI remote docker support, but I’m trying to not use compose here.