2017-04-24 8 views
2

用ドッカー作曲を使用している間、私は、以下のものを使用してPHP 7.1 Webアプリケーションを開発しています:エラー:古い「gulpfile.js」を解除することができない(パーミッション拒否)開発環境

  • のSymfony 3.2
  • ドッカーdocker-compose up -dを実行している場合1.12.0
  • のUbuntu 16.04のx64

を構成する、私のバインドマウントプロジェクトのディレクトリの所有者とグループがrootに変更されます。

error: unable to unlink old 'gulpfile.js' (Permission denied) 
fatal: Could not reset index file to revision 'HEAD^'. 

Changing the project directory's owner and group戻って私のユーザーにエラーを削除します。私は、変更をコミットまたはgit pullと私のリモートから引っ張ってみてくださいいつでもこのように、私は次のように表示されます。 Docker Composeで開発中にこれらのユーザー権限の競合を防止する簡単な方法はありますか?ここで

EDIT
は私の現在のディレクトリ構造の概要は次のとおりです。

dockerComposeAndProjectDir/ 
|-- projectDirectory/ 
|-- dockerComposeDirectory/ 
    |-- docker-compose.yml 

答えて

1

このdocker (err... moby!) issue

If you chown the volume (on the host side) before bind-mounting it, it will work.
In that case, you could do:

mkdir /tmp/www 
chown 101:101 /tmp/www 
docker run -v /tmp/www:/var/www ubuntu stat -c "%U %G" /var/www 

(Assuming that 101:101 is the UID:GID of the www-data user in your container.)

Another possibility is to do the bind-mount, then chown inside the container.

Using volumes just works assuming the image has data at the path your mounting to.
Using binds uses the host path's UID/GID.
UID/GID in the container is the same as UID/GID on the host... even if user/group names don't match, UID/GID is what matters here.

で述べたように、私はを参照さ210〜phpdocker-io/base-images/php/7.1 Dockerfile
ザ・OPは結論:

The php:7.1-fpm Dockerfile indicates that the php-fpm service would be run as www-data , so I was incorrect about the container's user.
Chowning the volume after the initial bind mount seems to work.
Anytime the volume needs to be recreated by Docker Compose, I have to chown it again, which gets a little annoying, but it does solve my issue.

+0

私は 'ドッキングウィンドウ・作曲アップ-d'を実行する前に、私のユーザーのUIDとGIDを使用して、私のホストからボリュームをchowningみました。しかし、upコマンドを実行した後、バインドされたマウントされたプロジェクトディレクトリは引き続き所有者とグループとしてrootになりました。 –

+0

投稿した問題を見ると、コンテナがボリュームをマウントした後にエントリポイントスクリプトを使用して手動で所有者/グループを変更する以外の解決策を誰も見つけられていないことがわかりました。 –

+0

@ChristianElowskyホストとコンテナのuid/gidが同じであることを確認する必要があります。 – VonC

関連する問題