# Connecting Containers — Docker Fundamentals: Images, Containers and Compose

Source: https://www.skillbyai.com/en/docker/docker-connecting-containers

> Create user-defined networks so containers reach each other by name instead of IP address.

## docker network create

Containers on the same user-defined network resolve each other by **container name** through Docker's built-in DNS — no hardcoded IPs.

```bash
docker network create app-net
docker run -d --name db --network app-net postgres:16
docker run -d --name api --network app-net -e DB_HOST=db my-app:1.0
# inside 'api', http://db:5432 just works
```
