Issue with documentation on using chown to fix permission denied problems

Issue #20 new
Martin Foot created an issue

Hi,

Apologies if this isn't the place to raise this.

According to the documentation on this project's overview page and the confluence page under the "Permission denied on files created within a Docker container" the suggestion is to pass the user's ID to the container and have the container run chown on the files it's created with that ID at the end.

I'm spinning up elastic instances and running a single stage that builds the following image in one task, then runs the container with the HOST_UID environment variable set as the second:

FROM ubuntu:12.04
WORKDIR /data
CMD rm -rf foo && touch foo && chown -R $HOST_UID foo && ls -al && exit 1

The exit 1 is to test the foo file is deletable when re-running the job - it'll fail to clean the working directory if it's owned by root.

/data is mounted as ${bamboo.working.directory} when the container is spawned.

I'm using plugin version 5.10.2.

The "Container environment variables" box contains HOST_UID=$UID as per the documentation.

I've tried using both CMD and ENTRYPOINT as well as overriding the command that's being run using the "Container Command" parameter and none of these cases $UID evaluated. Instead it is passed as the string "$UID" and chown fails with chown: invalid user:$UID'`.

I have a workaround for now - the elastic AMI runs the docker user as id 500 so I can hard code it.

Am I missing something or is the documentation incorrect?

Comments (3)

  1. Derek Gray

    I'm having the same issue - did you resolve it? Except I'm getting a value of empty string for GID.

  2. François Yacob

    Hi all,

    Just to share that i had the same problem, the variable $UID is not set correctly when docker is invoked by elastic agent (remote and local agents are fine) So you need to run the command 'id' : https://linux.die.net/man/1/id

    I set the variable HOST_UID to ìd -u` (with back quotes)

    François

  3. Log in to comment