Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43590

docker.inside() breaks container environment.

    Details

    • Similar Issues:

      Description

      We have PATH set on our build slaves (via configure -> Node properties -> Environment Variables) that won't work in most docker containers.  Specifically, we use /usr/local/bin:/a/bin.  Note how /usr/bin and /bin aren't in the PATH (which is where cat usually is located.

      Normally, the docker.inside() command's docker run isn't setting the -e PATH=... flag.  But every so often it uses the PATH from the build slave configuration which causes the docker run to not find cat

       

      docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"cat\": executable file not found in $PATH".

       

      I was able to track this down by modifying docker-workflow to not mask the PATH: https://github.com/jenkinsci/docker-workflow-plugin/pull/96

      I don't know what the expected behavior (overriding the PATH on a container seems like a "Bad Idea", since the container may-or-may-not be in LSB/POSIX layout) is supposed to be.

      It is clear that this random flipping between behaviors is bad.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Yes, though there are some limitations to that.

            Show
            jglick Jesse Glick added a comment - Yes, though there are some limitations to that .
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Christian Höltje
            Path:
            src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java
            http://jenkins-ci.org/commit/docker-workflow-plugin/e04959ea87d391ec89965c760b9d054b73bed317
            Log:
            Don't pass PATH to docker containers

            Docker containers usually have special PATHs; the PATH defined
            in on the Agent won't make sense for the container.

            JENKINS-43590 docker.inside()'s -e flags are random

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christian Höltje Path: src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java http://jenkins-ci.org/commit/docker-workflow-plugin/e04959ea87d391ec89965c760b9d054b73bed317 Log: Don't pass PATH to docker containers Docker containers usually have special PATHs; the PATH defined in on the Agent won't make sense for the container. JENKINS-43590 docker.inside()'s -e flags are random
            Hide
            ndeloof Nicolas De Loof added a comment -

            I think blocking PATH isn't a correct fix.

            Environment is built from various sources, including Computer.getEnvironment(), which returns node's `PATH`.

            Tool installers do amend this using `PATH+` syntax

            docker-pipeline should replace Computer.getEnvironment() result with the actual `env` from container, so this mechanism works as expected.

            Show
            ndeloof Nicolas De Loof added a comment - I think blocking PATH isn't a correct fix. Environment is built from various sources, including Computer.getEnvironment(), which returns node's `PATH`. Tool installers do amend this using `PATH+` syntax docker-pipeline should replace Computer.getEnvironment() result with the actual `env` from container, so this mechanism works as expected.
            Hide
            docwhat Christian Höltje added a comment -

            Nicolas De Loof

            I didn't even know that was possible, but it makes sense.  Do we need a new issue for that?

            Show
            docwhat Christian Höltje added a comment - Nicolas De Loof I didn't even know that was possible, but it makes sense.  Do we need a new issue for that?
            Hide
            hathaways Rong Shen added a comment -

            I agree with Nicolas De Loof

            This code change actually break our pipeline that passes PATH environment from hosts.

            Docker container path should be an optional overwrite, instead of blocking!

            Show
            hathaways Rong Shen added a comment - I agree with Nicolas De Loof This code change actually break our pipeline that passes PATH environment from hosts. Docker container path should be an optional overwrite, instead of blocking!

              People

              • Assignee:
                Unassigned
                Reporter:
                docwhat Christian Höltje
              • Votes:
                9 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated: