Reputation: 1444
Here's what my Dockerfile looks like for an image I'm creating.
FROM python:3.7-alpine
COPY requirements.txt /
RUN pip install -r /requirements.txt
ENV U_PATH="a"
WORKDIR $U_PATH
I override the env variable U_PATH
when I call it using docker run -it -e U_PATH=/mnt temp:v1 /bin/sh
but the WORKDIR
is set during build time and I cannot change that during runtime.
Is there any way to dynamically set the working directory at runtime by passing an env variable?
Upvotes: 1
Views: 2706
Reputation: 33203
While not an environment variable, don't forget you can alter the working directory of a Pod's container via the workingDir:
PodSpec field
containers:
- name: foo
image: 'temp:v1'
workingDir: /mnt
Upvotes: 3