I want deploy a 'prismagraphql/prisma:1.34' container using :
- docker-compose version (1.29.2)
- docker 20.10.9
- CentOS 8.4.2105
but when i use 'host.docker.internal' on host not working. So i try to use :
extra_hosts:
- "host.docker.internal:host-gateway"
My project three files :
datamodel.prisma :
type User {
id: ID! @id
name: String!
}
prisma.yml :
endpoint: http://localhost:4477
datamodel: datamodel.prisma
docker-compose.yml :
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
restart: always
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "4477:4477"
environment:
PRISMA_CONFIG: |
port: 4477
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: postgres
host: host.docker.internal
database: postgres
schema: public
user: postgres
password: yrt
rawAccess: true
port: '5432'
migrations: true
I try many incidents to disable firewall add to /etc/hosts ... => NOT WORKING
Here i create a GitHub repo : https://github.com/performautodev/local-prisma-1.34-using-docker-compose-1.29.2-docker-20.10.9-on-CentOS-8.4.2105
CodePudding user response:
host.docker.internal
is not supported on Linux. Have a look at this StackOverflow answer on the workaround.
CodePudding user response:
✔️ Solved :
The answer is to use the output of this command :
ip route | grep docker0 | awk '{print $9}'
OR
[root@localhost dev]# ifconfig docker0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:e6ff:fe93:a426 prefixlen 64 scopeid 0x20<link>
ether 02:42:e6:93:a4:26 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1 bytes 90 (90.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
and use the line :
inet 172.17.0.1
so the yml file look like this :
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
restart: always
ports:
- "4477:4477"
environment:
PRISMA_CONFIG: |
port: 4477
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: postgres
host: 172.17.0.1
database: postgres
schema: public
user: postgres
password: 'YOUR_PASS'
rawAccess: true
port: '5432'
migrations: true
IMPORTANT: my /etc/hosts is as default :
[root@localhost dev]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
issue refs :
https://github.com/docker/compose/issues/8771