Detailed Docker create a PHP development environment encountered permissions problem solution _docker

Source: Internet
Author: User
Tags fpm php development environment php framework

I recently ran the company's development and test environment to Docker, because development, testing is basically loading code to the site, and then reload the directory, mount to the mirror directory such as: I use the Docker-compose

# development.yml
version: ' 2 '
services:
 php-fpm:
  image:jackluo/php-fpm:5.6.3
  restart:always
  volumes:
   -/www:/var/www/html
   -/data:/usr/local/var/log
  extra_hosts:
   -"cache.redis.com : 192.168.9.111 "
   -192.168.9.111:192.168.9.111"  
 Web:
  image:index.alauda.cn/library/nginx
  Restart:always
  Links:
   -php-fpm
  volumes:
   -./CONFIG:/ETC/NGINX/CONF.D
   -./data:/var/log/ Nginx
  volumes_from:
   -php-fpm
  ports:-
   80:80
  expose:
   -80

Above the

jackluo/php-fpm:5.6.3 This is my own pull the official mirror down to add something, specifically in GitHub have docker-library inside

At present, the company's PHP framework is thinkphp, thinkphp will generate cache files and directories, PHP image of the official running user is www-data, the previous solution is as long as two users agree on it, so I created a local www-data users such as
All give the Www-data permission, and then look at the runtime above the host's generation is what permissions
All are 33, 33 is what user???? , I'll see what's inside the Docker, right?
found that the permission to mount is 1000, and that PHP generated becomes www-data this

And then I visit again, the Web page
Web page display, no write permission, this is ma meaning it?

In fact, this problem, plagued me for a long time, my general solution is directly on the runtime to 777 of the permissions, but, if the new generated PHP page, every time to perform to 777 of the permissions, really feel bad, roaming, http://stackoverflow.com/ Finally found the solution. The official solution is

From PHP:5.6-FPM

If you're a Mac

RUN usermod-u 1000 www-data && usermod-g staff Www-data

So the permissions generated by the PHP cache are consistent

Problem, just like that, solve the bird
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.