1

I've got a docker container that has PHP-FPM in it with a www-data user. I have a volume that maps my local app to the /var/www/html directory. I found the UID of the www-data (let's say 33). On my local machine, I chown'd the application directory to 33:hostuser, where 33 is the www-data user in Docker, and hostuser is the group I belong to on the host. Now PHP-FPM can write to logs and such in the application, and I can write the files locally.

Now the tricky part: I'm working on getting PhpStorm to run PHPUnit tests, and I'm setting the docker container as a remote interpreter for PHP. In other words, PhpStorm will HHS into the container and run the tests. So now I need to create a new user in the container that I can SSH into. Now the problem: this new user is not the owner of the app directory (www-data is), and the group doesn't belong to anyone within the container.

Am I going about this the right way? If so, what's the best way to let all 3 users have access to the container? I was thinking of enabling SSH for the www-data user, but I'm having trouble getting that to work, and I'm not sure it's a good idea anyways.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
timetofly
  • 2,957
  • 6
  • 36
  • 76
  • Latest PhpStorm 2016.3 allows to work with Docker-based interpreters .. so (as I understand (not a Docker user here)) it should not require SSH login for that... – LazyOne Dec 07 '16 at 09:47

1 Answers1

0

As in this example, you could define a www-data user (not just group), which you could then use to ssh in (meaning you would add in ~www-data/.ssh/authorized-keys your public key)

# ensure www-data user exists
RUN set -x ; \
  addgroup -g 33 -S www-data ; \
  adduser -u 33 -D -S -G www-data www-data && exit 0 ; exit 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I currently have the app directory owned by "33" (nginx in the container, invalid in host) and grouped owned by "1000" (myuser on host, invalid in container). Are you saying to create the www-data on the host machine with UID 33, and set the group in the application directory to 33 as well? And add the new user to group 33? – timetofly Dec 07 '16 at 20:51
  • @Blossoming_Flower the example used 33 for the guid, but in your case, you can keep 1000. – VonC Dec 07 '16 at 21:20