Editing /etc/resolv.conf in a running container does not stick — Docker overwrites it on start and on networking changes. Configure the resolver at one of three levels:

Per container:

docker run --dns=1.1.1.1 --dns=8.8.8.8 myimage
docker exec -it <container> cat /etc/resolv.conf

Per Compose service:

services:
  app:
    image: myimage
    dns:
      - 1.1.1.1
      - 8.8.4.4

Daemon-wide, in /etc/docker/daemon.json, then sudo systemctl restart docker:

{
  "dns": ["1.1.1.1", "8.8.8.8"]
}

--dns on the container overrides the daemon setting.

Bind-mounting your own file over the path is the fourth option, and worst:

docker run -v /path/my-resolv.conf:/etc/resolv.conf myimage

It survives restarts but stops Docker managing the file, breaking anything depending on Docker’s own name resolution inside the container.

Usual case: a container that must query a LAN resolver — AdGuard Home or Pi-hole — where the daemon-wide setting is wrong, since it sends every container there. See DNS troubleshooting for a container timing out against an internal upstream.