Next: , Previous: , Up: Top   [Contents][Index]


7 Using Pies as Entrypoint for Docker Container

Another use for pies is as an entrypoint in a docker container. This is similar to the init mode described in the previous chapter in that pies runs with PID 1. However, in this case pies uses its regular configuration file.

When started with PID 1 from a docker container, pies tries to detect the fact automatically and switch to the entrypoint mode. As of version 1.6, this detection might fail in containers run under Kubernetes. For such cases, use the --no-init option to inform pies that it should run in entrypoint mode.

The following Dockerfile fragment illustrates how to configure pies to be run from a container:

COPY pies.conf /etc
ENTRYPOINT [ "/usr/sbin/pies", "--foreground", "--stderr" ]

It is supposed, of course, that the configuration file pies.conf is available in the same directory as Dockerfile.

It is a common practice to supply configuration settings via the environment variables. To implement it in pies.conf, use either expandenv or shell flag (see Early Environment Expansion). For example:

  flags expandenv;
  command "syslogd -n -R $LOGHOST";

This will expand the environment variable LOGHOST and pass its value as one of the arguments to syslog. The usual shell syntax is supported. For example, to provide a default value for the -R option above (in case LOGHOST is empty or undefined), use:

  flags expandenv;
  command "syslogd -n -R ${LOGHOST:-172.19.255.255}";

Quite often a need arises to expand environment variables in other parts of the configuration file and to conditionally exclude portions of configuration, depending on whether a particular variable is set. The following sections describe two approaches to solving this problem.


Next: , Previous: , Up: Top   [Contents][Index]