I have this docker-compose
file where I have a couple of services:
version: "3.8"
services:
app:
container_name: mobile_app_api
env_file:
- .env.development
command: npm run watch:dev
build:
context: .
target: development
dockerfile: ./Dockerfile
restart: always
volumes:
- /usr/src/app/node_modules
- ./:/usr/src/app
depends_on:
- postgres
- redis
extra_hosts:
- host-machine:host-gateway
network_mode: host
redis:
image: "redis:alpine"
container_name: mobile_app_cache
postgres:
image: postgres
container_name: mobile_app_database
restart: "unless-stopped"
environment:
TZ: 'GMT'
PGTZ: 'GMT'
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mobile_app_database
volumes:
- /:/data/postgres
network_mode: host
Api is supposed to work on localhost:3333
, but when I start this with docker-compose up --build
in terminal I get this:
mobile_app_api | server running on http://[::1]:3333
And here is 2 things.
- Why does it work on
IPv6
? - How can I change host and make it work on
localhost
?
PS. My computer is MacOS, but in settings I have turned off IPv6
.
I was trying to use host.docker.internal
(and gateway.docker.internal
) in my compose file, but it didn't work:
extra_hosts:
- host.docker.internal:host-gateway