Using sed in dockerfile

270 Views Asked by At

I am a doubt about how to use a sed command for change default values in osticket app. I am using a docker file for changing the default value, but I am using wrong wall.

Below my dockerfile code:

cd /osticket && \
    mv /osticket/__download__/upload/* /osticket && \

    sed -i -E 's/%CONFIG-DBHOST/ip/' ./upload/include/ost-config.php
    sed -i -E 's/%CONFIG-DBNAME/dbname/' ./upload/include/ost-config.php
    sed -i -E 's/%CONFIG-DBUSER/username/' ./upload/include/ost-config.php
    sed -i -E 's/%CONFIG-DBPASS=password/' ./upload/include/ost-config.php
    rm -fr /osticket/__download__

When I run docker build, show me the message

error response from daemon: dockerfile parse error line 39: unknown instruction: SED

1

There are 1 best solutions below

6
Pedro Rodrigues On

You need to use the RUN instruction (as if, for example: RUN sed -i -E 's/%CONFIG-DBHOST/ip/' ./upload/include/ost-config.php.) You can't simply write the commands in the Dockerfile, it will not recognize them.

Please give the documentation a look: https://docs.docker.com/engine/reference/builder/#run