Docker4drupal: Composer does not seem to work

Created on 3 Oct 2016  路  12Comments  路  Source: wodby/docker4drupal

Hi !
I am trying to work with docker4drupal on my local environment, based on Windows 10 (using Hyper-V) and Docker 1.12. I would like to use composer to instantiate my project but as interactive mode is not yet supported on Windows, I have to pass the -d flag when using docker-compose exec command.
At the end, following composer command just returns anything and I don't know how to debug:
docker-compose exec -d --user 82 php composer create-project [....]
Do you think this issue is due to my local environment? Has anyone already experimented this kind of issue? Any idea?
Thanks in advance for your support.
Junod

help wanted

Most helpful comment

I guess @bircher doesn't need sshd, which is the service, but a ssh client to connect from the container to external services. Plus a way to add ssh keys / credentials to ~/.ssh.

All 12 comments

I also have a question for using composer, namely that ssh does not seem to be available in the php container and thus composer can not fetch from private repositories.

Hi @bircher,

There is no place for sshd in the php container, it caused by docker best-practice "one service per container". But SSH available as an additional container, you'll find more info in #39.

@Junod do you try enter the container and execute composer ... within a container?

docker-compose exec --user 82 php sh
composer create-project ...

I guess @bircher doesn't need sshd, which is the service, but a ssh client to connect from the container to external services. Plus a way to add ssh keys / credentials to ~/.ssh.

@drubb thank you for the clarification.

@bircher I've added SSH client in PHP container: docker-compose exec --user=82 php ssh [email protected]. You can set SSH key via env var SSH_PUBLIC_KEY: "your ssh pub key..." in PHP container.

Shouldn't it be the private key?

@drubb sure, my mistake.

I've implemented the way to forward ssh keys into container via volume.
Mount host machine ~/.ssh to /mnt/ssh, and it will be available in container in the /home/www-data/.ssh directory.

@PavelPrischepa the ssh keys work nicely now, thanks!
I have, however, another concern: the UID and the permissions.
As far as I know the php process runs as user 82 when creating the uploaded files etc. that is great. Correct me if I am wrong, but user 82 is not supposed to edit the drupal files, and as such is not supposed to run composer (or drush/console).
So would it be an option to add a non-root system user (with configurable UID) that could run the scripts? And incidentally that would solve the permission and file owner problems that I have now.

@bircher If you create some files under user with configurable UID, probably, you'll face the issue with Nginx access to these files (see for deatils).

Actually that is exactly the point.
Nginx should not have write access to anything outside of sites/default/files and neither should php when it is serving the website.
When running composer and drush on the other hand it should...

Anyway I had a problem with the patch version in the container that was not accepting all the arguments so I am now using yet another container for composer...

@bircher Thank you for the feedback. I'm going to test the approach with dynamic UID.

Btw, I've updated patch tool, it should work well.

Correct me if I am wrong, but user 82 is not supposed to edit the drupal files, and as such is not supposed to run composer (or drush/console).

Btw @bircher, you can modify drupal files under www-data user (UID 82). Just specify an appropriate permissions. For example:

chown -R <Your user UID on a host machine>:82 /var/www/html
chmod -R 775 /var/www/html

So you can modify files from a host machine and from a container.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

suricactus picture suricactus  路  9Comments

ChristianNally picture ChristianNally  路  8Comments

LordFransie picture LordFransie  路  3Comments

quietone1 picture quietone1  路  10Comments

webdobe picture webdobe  路  5Comments