docker: sed replacement fails only during docker build

Viewed 22

I'm baffled by this problem. If I run this:

FROM jtreminio/php:8.1
RUN sed -i 's,^\(user \).*,\1'www\;',g'  /etc/nginx/nginx.conf

I get this error:

#0 0.339 sed: can't read /etc/nginx/nginx.conf: No such file or directory

But the file is there, and if I run sed from bash or with docker run, it works:

$ docker run jtreminio/php-nginx:8.1 sed -i 's,^\(user \).*,\1'www\;',g'  /etc/nginx/nginx.conf

CONTAINER ID   IMAGE                     COMMAND                    CREATED          STATUS                      PORTS                                                              NAMES
97a971771a05   jtreminio/php-nginx:8.1   "sed -i 's,^\\(user \\…"   25 seconds ago   Exited (0) 24 seconds ago                                                                      gifted_nightingale

what gives?


UPDATE:

RUN cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

this also fails. It really looks like the file's not there. I suppose it's dynamically generated at start up. I'll keep investigating.

0 Answers
Related