0

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

Robert
  • 7,394
  • 40
  • 45
  • 64

1 Answers1

0

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

Pedro Rodrigues
  • 637
  • 6
  • 16
  • Yeap!!!This is my code: RUN apk update && \ sed -i -E 's/%CONFIG-DBHOST/ip/' ./upload/include/ost-config.php && \ sed -i -E 's/%CONFIG-DBNAME/name/' ./upload/include/ost-config.php && \ sed -i -E 's/%CONFIG-DBUSER/teste/' ./upload/include/ost-config.php && \ sed -i -E 's/%CONFIG-DBPASS=teste/' ./upload/include/ost-config.php && \ after execute docker build: sed: -e expression #1, char 23: unterminated `s' command please help me!! – João Paulo Sapi de Paula Mar 14 '23 at 13:40
  • That seems like an error from one of the SED commands (probably the last one, since you used `=` instead of `/`). Also, just a note, you can have more than one RUN command in the Dockerfile... You don't need to put all the commands together – Pedro Rodrigues Mar 14 '23 at 13:51
  • I understood!!! I am trying here!!! – João Paulo Sapi de Paula Mar 14 '23 at 14:11
  • Hello Pedro! Did not work!!!! Run #sed -i '/%CONFIG-DBHOST=ip/' ./upload/include/ost-config.php && \ #sed -i '/%CONFIG-DBNAME=dbname/' ./upload/include/ost-config.php && \ #sed -i '/%CONFIG-DBUSER=teste/' ./upload/include/ost-config.php && \ #sed -i '/%CONFIG-DBPASS=teste/' ./upload/include/ost-config.php – João Paulo Sapi de Paula Mar 14 '23 at 18:23
  • Hi João. You did the opposite, you need to replace the `=` with `/`. Please check on the internet how `sed` works (example here: https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/) If you still have problems after that, please create another question in SoF instead of discussing the problem here, since the topic described on the question is solved (and please mark it as solved, so it can help others :)) – Pedro Rodrigues Mar 14 '23 at 19:13
  • ok, thanks! I am go test and search!! – João Paulo Sapi de Paula Mar 15 '23 at 18:10