Docker Community Forums

Share and learn in the Docker community.

Changes are not committed after each RUN in Dockerfile

Here is my dockerfile:

FROM internetsystemsconsortium/bind9:9.11

RUN sed -i -e "/listen/i allow-recursions" /etc/bind/named.conf.options&&ls -l /etc/bind/named.conf.options
RUN ls -l /etc/bind/named.conf.options
CMD ["cat", "-vte", "/etc/bind/named.conf.options"]

When I build this image, the first ls -l returns todays date (and if I typed the file, I would see the words “allow-recursions” inserted in the named.conf.options file. However, the second ls command display the date of Jul 21 18:27 for the same file and my changes are gone. I am running docker on ubuntu 20.04 server and I upgraded the docker server (engine I presume) to 20.10.7 which is the latest.

Actually, it turns out that the change I am trying to make is in a volume already declared and as per the documentation all changes to volumes are discarded. The fix is to make the change in the CMD