I am using GitHub Actions to make the C.I. of project and when I run the container in the same network as the database they don’t connect and I get the error: Error: getaddrinfo EAI_AGAIN 'lightformsdev'
.
This is my GitHub Actions .yaml file:
name: Continuous Integration
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'npm'
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
deploy:
needs: build
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Remove existing container
run: docker rm -f clightformsapi
- name: Remove existing image
run: docker image rm ilightformsapi
- name: Build the new image
run: docker build -t ilightformsapi -f Dockerfile.main .
- name: Run new container
run: docker run --net lightformsdevops --name clightformsapi -p 3030:3030 --env-file ~/desenv/.env.prod -d ilightformsapi
- name: Confirmation
run: echo ON AIR
It runs, and the status is succeeded but when I do a docker logs -f clightformsapi
the error appears.
I tried to create a new network inside the container, but I get an error always I have to rerun the action.
My network when I inspect it is:
[
{
"Name": "lightformsdevops",
"Id": "fcb6b2d921bd77c8a493530909f920ea7fe3da12728578a005aacce972ffd42b",
"Created": "2024-04-08T23:03:59.655350666Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.20.0.0/16",
"Gateway": "172.20.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"708879215a2a9b02e8cd0fb20b9b1d6c8c4d8984dd4cc21f22734e2286e4c88b": {
"Name": "lightformsdev",
"EndpointID": "bac3524810ae5b56b50fcefd669c7e2ccaa2aa7c22625dbd54b75bb440358e26",
"MacAddress": "02:42:ac:14:00:02",
"IPv4Address": "172.20.0.2/16",
"IPv6Address": ""
},
"7b27b0bc6ba509202e81297c4211e3c47d37e4dd75733c0dc1dfeb23f470f349": {
"Name": "clightformsapi",
"EndpointID": "0bffa651a751da8d002e25800c6eb44b1a3d0ead4c6cb02d69e3c522278b86b7",
"MacAddress": "02:42:ac:14:00:03",
"IPv4Address": "172.20.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]