Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Docker cannot write files to host with correct permissions. Why UID is 0 when running builds? Edited

Correction: the UID is not the problem. For some reason the mounting of the docker volumes is still not working correctly and suffering some permission errors on bitbucket.

In order to cache the composer folder i was mounting ./.composer to /home/composer/.composer .

- ./.composer:/home/composer/.composer


This was causing permission errors, so changed it so that the current folder is also mounted at /home/composer  but this is also not working.

- ./:/home/composer/

I have also added step

- "ls -la .composer/cache/repo"

in the pipeline file to debug what is happening and this is failing. 
+ ls -la .composer/cache/repoCreating build_composer_1 ... donels: .composer/cache/repo: No such file or directory

And also it is clear from composer install that the container is not able to write to the cache:



Cannot create cache directory /home/composer/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cacheCannot create cache directory /home/composer/.composer/cache/files/, or directory is not writable. Proceeding without cacheLoading composer repositories with package informationInstalling dependencies (including require-dev) from lock file

How am i supposed to leverage the composer caching as shown on this document if my container cannot write the files to the host?

Original post below

--------------------------------

Problem, when running a build on bitbucket the runner has not UID and thus volumes cannot be mounted correctly, See step output :

 + export UID && echo " UID: $UID "
UID: 0

 

Mounting a container volume with the right UID is necessary so that new files can be mounted and written back to the volume.

In my case this is stopping composer (php) when creating files back to the volume and so the vendor folder needs to be recreated from connecting back to packagist every time. I could also try to cache manually the vendor folder but Bitbucket is a very different and not standard environment so I cannot really play too much with it also because of the 50 minutes build time limit on a monthly basis.

In a similar article but back from time it looks like docker was able to write files back as the container user which is usually root but without a UID mapping this cannot be achieved with the correct permissions.

 

https://community.atlassian.com/t5/Bamboo-questions/Bamboo-docker-Could-not-remove-working-directory-for-plan/qaq-p/66819

Can someone suggest how to achieve a correct UID mapping on bitbucket?

here is also an extract of the bitbucket pipelines yml file

 

options:
docker: true

pipelines:
default:
- step:
caches:
- docker
- composer
script:
- "export UID && echo \" UID: $UID \""
- "export UID && make tests_ci"

definitions:
caches:
composer: ./.composer 

 

1 answer

It is quite common indeed, all the issues i see about permissions on bitbucket pipelines are quite uncommon though as you can see maybe bitbucket clone dir subdirectories might not be mountable as shown here. I will try to refactor and see if it works 
https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-pipelines-how-can-I-map-a-volume-to-docker-to-expose/qaq-p/686951#M22253

Like Radek Antoniuk likes this

BTW i have updated my post with some extra information.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

644 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you