Open Insidexa opened 4 years ago
Hello, I tried with adding the following commands to the build spec.
docker inspect --format '{{ .NetworkSettings.IPAddress }}' sample-postgres
Connected to 172.18.0.2. Escape character is '^]'.
Seems like it works. Could you try it out and see if it works or not?
Thanks! Xin
@xinw0911, thanks for the answer
[Container] 2020/03/25 06:45:51 Running command ipAddress=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' sample-postgres)
[Container] 2020/03/25 06:45:51 Running command telnet $ipAddress 5432
telnet: Unable to connect to remote host: Connection timed out
Trying 172.17.0.3...
CodeBuild logs
Build Command:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:3.0" -e "ARTIFACTS=/home/user/CodeBuildLocal/" -e "SOURCE=/home/user/CodeBuildLocal/sample-web-app" -e "BUILDSPEC=/home/user/CodeBuildLocal/sample-web-app/buildspec.yml" -e "INITIATOR=user" amazon/aws-codebuild-local:latest
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done
Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1 | WARNING: no logs are available with the 'local' log driver
build_1 | WARNING: no logs are available with the 'local' log driver
But it works in AWS CodeBuild ( non local )
@Insidexa are you running OSX? I wasn't able to connect to postgres either until I changed host to host.docker.internal. https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
@joni- I am not using OSX, I use Fedora 32
Ive run into the same issue. Using docker-compose to bring up containers and connect to them does not work using 'localhost' in the local runner but found that it works fine in the actual codebuild project. minimal reproducible example here https://github.com/ThrowsException/aws-docker-in-docker just doing a simple curl from the script to a running nginx container.
I have
buildspec.yml
Postgres already created and running.
Postgres connection string:
postgresql://sample:sample@127.0.0.1:5432/sample
Can`t connect to postgres in CodeBuild. I got next error:
Docker inspect command of sample-postgres
I trying connect with telnet in
buildspec.yml
to database containersample-postgres
withIPGateway
,IPAddress
and got error connection refused