I am new to circleci and so far I was really happy with it.
Now I ran into a problem and I don’t know what I’m doing wrong.
Maybe this is something very easy, but I don’t see the it.
I can’t make containers talk to each other on circleci.
Basically what I wanted to do is start a server container and a client container, and then let them talk to each other.
I created a minimal example here: https://github.com/mRcSchwering/circleci-integration-test
README.md basically explains the desired outcome.
I have a
.circleci/config.yml like this:
version: 2 jobs: build: docker: - image: docker:18.03.0-ce-git steps: - checkout - setup_remote_docker - run: name: Install docker-compose command: | apk --update add py2-pip /usr/bin/pip2 install docker-compose docker-compose --version - run: name: Start Container command: | docker-compose up -d docker-compose ps - run: name: Let client talk to server command: | docker-compose run client psql -h server -p 5432 -U postgres -c "\l"
In a docker container,
docker-compose is installed, which is then used to start a
server and a
client (postgres here). In the last step I am telling the
client to query the
server. However, it cannot find the
#!/bin/sh -eo pipefail docker-compose run client psql -h server -p 5432 -U postgres -c "\l" Starting project_server_1 ... ^@^@psql: could not connect to server: Connection refused Is the server running on host "server" (172.18.0.2) and accepting TCP/IP connections on port 5432? Exited with code 2
docker-compose.yml looks like this
version: '2' services: server: image: postgres:9.5.12-alpine networks: - internal expose: - '5432' client: build: context: . networks: - internal depends_on: - server networks: internal: driver: bridge
client is built from a dockerfile like this
FROM alpine:3.7 RUN apk --no-cache add postgresql-client && rm -rf /var/cache/apk/*
If I repeat everything on my Linux (also with docker-in-docker) it works.
But I guess some things work completely different on circleci.
I found some people mentioning that on circleci networking and bind mounts can be tricky but I didn’t find anything that can help me.
There is this doc but I thought I am doing this already.
Then there is the protobuf project from johanbrandhorst on github where he seems to do the same thing on circleci successfully.
But I cannot figure out what’s different there…
Anyway I would really appreciate your help. So far I have given up on this.