I want to run apache spark history on a docker image, to achieve this I had to change spark-defaults.conf and add this line
spark.history.fs.logDirectory /path/to/remote/logs
And then run start-history-server.sh
This work fine when I set the value statically, however I want the value to be set from an environement variable that will be set on the docker container on run time, so I want something like this:
spark.history.fs.logDirectory ${env.path_to_logs}
However this doesn't work since the spark-defaults.conf deosn't access env variable, so is there a solution for this or maybe add a parameter when running start-history-server.sh ?
Related
How do I set this environment variable when I run a .NET 6.0 docker file?
I have a docker image based off aspnet6.0 Docker file. By default the environment variable is set as Json. I want to set it to Simple without changing the code.
The console log formatter is here: https://learn.microsoft.com/en-us/dotnet/core/extensions/console-log-formatter
Can this be done?
I thought it would as simple as:
docker run --env LOGGING__CONSOLE__FORMATTERNAME=Simple <CONTAINER_NAME>
This does set an environment variable with this name. However it does not overwrite the environment variable it results in a duplicate setting. I would expect making the above command to overwrite the setting for: LOGGING__CONSOLE__FORMATTERNAME.
Therefore my console is still formatted as JSON and not in Simple format as I expect.
The reason is it not overriding the setting is the capitalisation should match the existing environment variable: Logging__Console__FormatterName
However the Docker container dotnet/aspnet has now reverted to the behaviour in 5.0 by not overriding the log format to JSON.
https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/6.0/console-formatter-default
I have seen some similar questions, but none of them appear to solve my problem. I want to add a user to a docker container and in my Dockerfile, I define the username with:
ARG USERNAME="some_user"
Instead, I want the username to be the current user's computer username, as obtained by running the command whoami in the local terminal.
So what I would like to have is something like
ARG USERNAME=$(whoami)
.
This $(whoami) should be obtained from the local system environment, and not from the docker container.
Is there a way to do this for dockerfiles? I have thought of .env and docker-compose solutions but these also require each user to set their own username according to my knowledge.
There is no integrated way to execute arbitrary commands on the host directly outside of a container using just docker build / docker-compose build.
So to execute an arbitrary command to get/generate the required information you'll need to provide a custom script / use another build system to call docker/docker-compose with the respective flags or maybe generate the .env file from a template / interactively.
If you only need the current user name you may want to use the $USER / $LOGNAME environment variables that are set by the system in many default configurations. But since these are just normal environment variables their values may be incorrect / empty / manually changed by the user, see this question.
I have an environment variable defined in my windows settings as a user variable.
It is called GITLAB_AUTH_TOKEN.
In my Dockerfile I am trying to assign this variable to an environment variable called GAT like so:
ENV GAT=${GITLAB_AUTH_TOKEN}
This results in the GAT env var to be blank inside my container.
I have seen that it may be possible via docker-compose but that is not a solution for me, as my RUN command relies on this variable.
I am trying to pass on environment variables to be read from an XML file inside a docker container running wildly app service and hosted inside REHL 7 image.
What I've done so far:
I've created an environment file as key value pair, for example: FILESERVICE_MAX_POOL_SIZE=5
I am running docker by referencing the environment file: docker run -d --env-file ./ENV_VARIABLES <myImage>
In the Dockerfile I copy the xml template I need: COPY dockerfiles/standalone.xml /opt/wildfly/standalone/configuration/standalone.xml
Inside the XML template I'm trying to reference the environment variable: <max-pool-size>${env.FILESERVICE_MAX_POOL_SIZE}</max-pool-size>
I can see those environment variables inside the running container as root but not as the wildly user which needs them. How can I make an attribute visible to a specific user other than root ?
Clearly I'm doing something fundamentally wrong here just not sure what ?
Thanks in advance for your help.
Problem solved: wildfly couldn't see the attributes because in my startup script I didn't add the -E flag for sudo to preserve environment variables.
I am trying to setup a dockerized Nagios. For that, I am using the already working image from jasonrivers: Dockerfile
Now, I need to slightly adjust the postfix, that is already installed in the image. I need to setup a relayhost so that e-mails that are sent from nagios are forwarded to my Mail-Server. Which should be as simple as setting the "relayhost" property in /etc/postfix/main.cf.
However, no matter how I adjust this value in my Dockerfile (I tried doing it with both sed and a COPY), when I inspect the /etc/postfix/main.cf file after starting the container the relayhost value was overridden to an empty value.
At first I thought that this has to do something with docker itself, I thought that somehow my steps in the Dockerfile that adjust this file did not end up affecting the final image. However, when I override main.cf with gibberish (like setting it's content to just "foo") then upon running the image, postfix throws some errors about it.
To put the words into code, consider this Dockerfile:
FROM jasonrivers/nagios:latest
RUN echo "relayhost = www.abc.com" > /etc/postfix/main.cf
Building this and then running the resulting image will result in a /etc/postfix/main.cf file with contents
relayhost =
I have tried using google to figure out how postfix works and why it does that, but the only suggestion I found was that something is configured in "master.cf", which it is not (you can download the image yourself and test all this yourself).
The JasonRivers/Docker-Nagios repo for the image has a feature in the postfix startup script to modify that setting overlay/etc/sv/postfix/run:
sed -i "s/relayhost =.*/relayhost = ${MAIL_RELAY_HOST}/" /etc/postfix/main.cf
Set the MAIL_RELAY_HOST environment variable to your host.
ENV MAIL_RELAY_HOST=www.abc.com