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.