INGInious icon indicating copy to clipboard operation
INGInious copied to clipboard

Docker Environments Breaking

Open javawolfpack opened this issue 7 months ago • 1 comments

Describe the bug I build a new grading container and when the container runs, the PATH environments no longer match what was built. As an example for Rust have the following:

# System-wide locations so all users share one toolchain/cache
ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \
    PATH=/usr/local/cargo/bin:$PATH

And the PATH in the container when grading or debug shell you can SSH into doesn't have cargo's bin in the path. I also tried setting the PATH in /etc/environment or profile and that resulted in the container fully failing to launch/work at all.

INGInious installation details

  • Version: 0.9.1

To Reproduce Steps to reproduce the behavior:

  1. Create grading container w/ modified PATH
  2. Submit

Expected behavior PATH should be the same as when running the container on it's own outside of the INGInious system or kind of defeats the point.

Additional context This has now also been detected at least in the debug mode of another container, least working for grading but somehow lacks g++ when you launch the debug shell. Seems like the same issue that somehow the way you're launch the docker containers is corrupting the system PATHs

javawolfpack avatar Sep 10 '25 23:09 javawolfpack

Hi,

The environment variables set with ENV in a Dockerfile are only set for the command that is run by Docker (that is, specified using CMD). Therefore SSH does not see them.

However, you should be able to use /etc/environment file to set system-wide environment variables. This is a workaround that we are already using here : https://github.com/INGInious/INGInious/blob/f8b6a03324321d0b267e7470b28805d96230c0d9/base-containers/base/Dockerfile#L47

This file is not sourced before Docker runs the CMD line. Therefore, you should keep your ENV lines too, otherwise they won't be available during typical runtime.

Beware when appending to the PATH using $PATH as it is already propagated to the container at buld time. For instance, if you write :

ENV PATH=$PATH:/folder1
RUN echo -e "\nPATH=$PATH:/folder2\n" >> /etc/environment

You will end up with PATH=...:/folder1 when the container is run "normally" but with PATH=...:/folder1:/folder2 when logging in SSH.

anthonygego avatar Sep 11 '25 08:09 anthonygego