/etc/resolv.conf so it points at the nameservers you actually want. Then the container restarts and the file is back to something else, usually whatever the Proxmox host uses. You edit it again, restart again, and the same thing happens. Nothing inside the container is doing this. Proxmox writes that file on purpose every time the container starts.
Once you see where the write comes from and where the values come from, the fix is a choice rather than a fight. This comes up often after migrations because the old VPS treated /etc/resolv.conf as an ordinary file the guest owned. In an LXC container on Proxmox, the host considers part of that file its responsibility.
What happens to a container's files before it boots
/. That shared design means the host can reach into the container's filesystem before any process inside it runs.
Proxmox uses that access. When you run pct start or click Start in the web UI, the start roughly goes like this:
- Proxmox reads the container config at
/etc/pve/lxc/<vmid>.conf. - It prepares the LXC config and calls LXC to start the container.
- Before the container's init process starts, a Proxmox hook runs with the container's root filesystem mounted.
- That hook detects the guest distribution and runs distro-specific setup code. The code writes the hostname, updates
/etc/hosts, writes network configuration for the interfaces defined in Proxmox, and writes DNS settings into/etc/resolv.conf. - Only after that does the container's init (usually systemd) start and read those files like it would on any machine.
Where Proxmox gets the nameservers it writes
nameserver and searchdomain. In the web UI they appear under the container's DNS settings. When they are set, Proxmox writes those values into the container's /etc/resolv.conf. When they are not set, Proxmox falls back to the host's own DNS configuration. That fallback is why the reset file often looks exactly like the host's /etc/resolv.conf.
After a migration, the second case is the usual one. The container was created with DNS left at the default, the old VPS's resolv.conf came across with the filesystem, and Proxmox replaces it at the first start. Nothing looks wrong until something depends on the old nameservers, such as an internal resolver, a split-horizon zone, or a resolver that is allowed through a firewall when the host's resolver is not.
You can confirm which case you are in from the host and from inside the container:
BASH
# On the Proxmox host: show DNS options for container 101 (no output means unset)
pct config 101 | grep -Ei 'nameserver|searchdomain'
# Inside the container: is resolv.conf a regular file or a symlink?
ls -l /etc/resolv.conf
cat /etc/resolv.confls -l check matters more than it looks. On many modern distributions, /etc/resolv.conf is not a plain file. It is a symlink into /run/systemd/resolve/ managed by systemd-resolved, or it is generated by resolvconf or a DHCP client. If that is the case, there may be two writers involved: Proxmox at start, and a service inside the container after boot. Before you blame Proxmox, check whether the file changes again a minute after boot, once services like systemd-resolved, NetworkManager, or a DHCP client have started.
Option one: configure DNS in Proxmox
BASH
# Set nameservers and search domain for container 101 (applied at next start)
pct set 101 --nameserver '192.0.2.53 192.0.2.54' --searchdomain 'example.internal'
# Restart the container so the setup step writes the new values
pct reboot 101Option two: tell Proxmox to leave the file alone
.pve-ignore.<filename> in the same directory as the file it would manage. If the marker exists, it skips that file.
For resolv.conf, the marker goes inside the container at /etc/.pve-ignore.resolv.conf:
BASH
# Inside the container: stop Proxmox from managing /etc/resolv.conf
touch /etc/.pve-ignore.resolv.conf/etc/.pve-ignore.hosts and /etc/.pve-ignore.hostname follow the same naming. The marker only affects the file it names, so Proxmox still sets the hostname and network config as usual. That is usually what you want. Turning off all guest setup with the unmanaged OS type in the container config is a much bigger switch, because it also stops Proxmox from writing network configuration.
A few details are easy to miss:
- The marker is checked at start, so it has no effect until the next container start. Fix the contents of resolv.conf first, then create the marker, then restart and confirm.
- The marker lives in the container's filesystem. If you restore the container from an older backup or rebuild it from a template, the marker may be gone and the overwriting comes back.
- If resolv.conf is a symlink managed by systemd-resolved, the marker stops Proxmox from touching it, but systemd-resolved still controls the contents. You then configure DNS through resolved's own settings, not by editing the file.
How to pick between them
nameserver and searchdomain in the container config and leave resolv.conf to Proxmox. If the answer is whatever runs inside the guest, such as a local caching resolver, a config management agent, or an application stack that ships its own resolver setup, use the ignore marker and manage DNS inside the container.
Avoid ending up with both. A common pattern after migrations is DNS values set in the Proxmox config and an ignore marker in the container that nobody remembers adding. The UI then shows one set of resolvers while the container quietly uses another. When DNS behaves oddly in a container, check four things in order: the pct config output, whether /etc/.pve-ignore.resolv.conf exists, whether resolv.conf is a symlink, and what the file contains after a full restart and a minute of uptime. Memory figures inside containers can be misleading for related reasons, covered in Why an LXC Container on Proxmox Shows the Host's Full RAM in free and top.
In short, the overwrite is not a bug. It is Proxmox doing setup at the one moment it controls, before the container starts. Decide which side owns DNS, configure it on that side only, and the file will stop changing under you.