0

I have a docker file that has an entry point which is an s2i/bin/run script:

#!/bin/bash

export_vars=$(cgroup-limits); export $export_vars

exec /opt/app-root/services.sh

The services.sh script runs php-fpm and nginx:

php-fpm 2>&1
nginx -c /opt/app-root/etc/conf.d/nginx/nginx.conf
# this echo to stdout is needed otherwise no stdout doesn't show up on the docker run output
echo date 2>&1

The php scripts are logging to stderr so that script does 2>&1 to redirected to stdout which is needed for the log aggregator.

I want to run sed or awk over the log output. Yet if I try:

php-fpm 2>&1 | sed 's/A/B/g'

or

exec /opt/app-root/services.sh | sed 's/A/B/g'

Then nothing shows up when I run the container. Without the pipe to sed the output of php-fpm shows up as the output of docker run okay.

Is there a way to sed the output of php-fpm ensuring that the output makes it to the output of docker?

Edit Note that I tried the obvious | sed 's/A/B/g' in both places and was also trying running the pipe in a subshell $(stuff|sed 's/A/B/g') in both places. Neither works so this seems to be a Docker or s2i issue.

simbo1905
  • 6,321
  • 5
  • 58
  • 86

1 Answers1

0

Try keeping sed arguments in double quotes.

php-fpm 2>&1 | sed "s/A/B/g"

SAB
  • 307
  • 4
  • 9
  • The question says that I tried that and that it doesn't work. – simbo1905 Apr 08 '18 at 08:16
  • I have seen some cases single quote didn't give us exact output inside shell script, so asked to try keep double quotes (") . – SAB Apr 08 '18 at 08:25