# Docker volume with www-data user

**URL:** <https://discuss.circleci.com/t/docker-volume-with-www-data-user/18456>\
**Category:** Build Environment\
**Tags:** docker\
**Created:** [November 30, 2017, 12:35pm UTC](https://discuss.circleci.com/t/docker-volume-with-www-data-user/18456 "2017-11-30T12:35:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukaszgoworko](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@lukaszgoworko](https://discuss.circleci.com/u/lukaszgoworko)\
**Post date:** [November 30, 2017, 12:35pm UTC](https://discuss.circleci.com/t/docker-volume-with-www-data-user/18456/1 "2017-11-30T12:35:14Z")

</div>

**Part of my docker compose file**

> ```
> version: "3.1"
> services:
> codecontainer:
> container_name: codecontainer
> build: .
> user: www-data
> volumes:
> - codecontainerdata:/var/www/html
> php:
> container_name: php
> restart: always
> build:
> context: ./build/php
> args:
> ENVIRONMENT: ${ENVIRONMENT}
> volumes:
> - codecontainerdata:/var/www/html
> - ./logs/php/:/var/log
> depends_on:
> - codecontainer
> user: www-data
> volumes:
> pgdata:
> codecontainerdata:
> 
> ```

- ✅ Both Dockerfiles creating same www-data user and group
- ✅ Dockerfile in Codecontainer copy files into /var/www/html
- ✅ all files in dir /var/www/html inside codecontainer are getting chown www-data:www-data
- ✅ docker-compose up

**Problem:**

- ❌ docker exec -ti -u www-data php ls -la /var/www/html =\> all files are owned root:root
- ❌ docker exec -ti php chown -R www-data:www-data /var/www
  - … chown: /var/www/html/README.md: Operation not permitted …

**Additional Information:**  
Working on my mac and on linux

the job from .config.yml

> ```
> integration_tests:
> docker:
> - image: docker:17.09.0-ce
> working_directory: ~/repo/Api/
> steps:
> - checkout
> - setup_remote_docker:
> version: 17.09.0-ce
> docker_layer_caching: true
> - run:
> name: install python3
> command: apk update && apk add --no-cache python3
> - run:
> name: Install Docker Compose
> command: |
> set -x
> VER="1.16.1"
> pip3 install docker-compose==$VER
> - run:
> name: Start container with docker compose
> command: |
> set -x
> docker-compose up --build -d
> environment:
> ENVIRONMENT: test
> APPLICATION_CACHE: false
> APPLICATION_DEBUG: false
> LOCALE: en
> - run:
> name: install dependencies
> command: |
> set -x
> docker exec -ti -u www-data php ./composer.phar install
> 
> - run:
> name: test db schema
> command: |
> set -x
> docker exec -ti -u www-data php ./bin/console doctrine:schema:validate --skip-sync
>             
> - run:
> name: run integration tests
> command: |
> set -x
> docker exec -ti -u www-data php ./composer.phar integ
> 
> ```

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [December 30, 2017, 9:19pm UTC](https://discuss.circleci.com/t/docker-volume-with-www-data-user/18456/2 "2017-12-30T21:19:53Z")

</div>

If you need to mount volumes, we would recommend using the `machine` executor. This is documented here: [https://circleci.com/docs/2.0/executor-types/#docker-benefits-and-limitations](https://circleci.com/docs/2.0/executor-types/#docker-benefits-and-limitations) and [https://circleci.com/docs/2.0/executor-types/#using-machine](https://circleci.com/docs/2.0/executor-types/#using-machine)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:40am UTC](https://discuss.circleci.com/t/docker-volume-with-www-data-user/18456/3 "2018-06-18T11:40:07Z")

</div>


