If that is in the same docker-compose.yml as the db
service then you should be able to make the following changes:
- No need to expose a port in the db service
- Add the adminer service to the local network that the db is also in
networks:
local:
- In the adminer gui put
db
as the server . This is because when using docker-compose containers in the same network can be accessed using their service name as defined in the docker-compose. This means theadminer
container should be able to connect to the hostnamedb
which will be the db container. Additionally this means you don’t need to expose the port for the db container as if containers are on the same network then they can access all of the other containers ports (unless you also want to access the postgres db from some other non-docker host on the server or externally).