On server A, we used "host.docker.internal" in one Docker container configuration to access this container from another container on the same server A. We wanted to use this Docker environment on another server - server B, but the hostname "host.docker.internal" still points to the IP address of server A.
Clearing the cache, complete reinstallation of containers did not help. Hostname "host.docker.internal" on server B still points to server A.
Question: where is the binding between the IP and the hostname "host.docker.internal" recorded? How can I update it to the correct IP address?
docker-compose.yaml
version: '3.2'
services:
postgres:
build:
context: .
dockerfile: ./docker_files/postgres.Dockerfile
container_name: ${POSTGRES_CONTAINER_NAME}
restart: always
ports:
- target: ${POSTGRES_TARGET_PORT} # the port inside the container
published: ${POSTGRES_PUBLISHED_PORT} # the publicly exposed port
protocol: tcp # the port protocol (tcp or udp)
mode: host
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- panter_docker_network
volumes:
- ${HOST_TRANSFER_DIRECTORY}:/tmp/host/
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
networks:
panter_docker_network:
driver: bridge
postgres.Dockerfile
:
FROM postgres:15.1
RUN set -eux; \
apt-get update && apt-get install -y \
vim \
zip \
procps \
locales \
lsb-release \
libicu-dev \
iproute2 \
unzip \
iputils-ping && \
mkdir /tmp/host/
USER root