
Dockerfilesとdocker-composeを介してPHP開発スタックを設定しました。ソースツリーとComposer Vendorフォルダをコンテナにマウントしました。私のホストのローカルユーザーはphilipp
IDを持ち1000
、私のコンテナはwww-data
ユーザーIDを持つユーザーを使用します33
。
マウントされたボリュームのIDをマッピングするためにマウントしました。lebokus/docker-volume-bindfs埋め込む:
docker plugin install lebokus/bindfs
これで、docker-compose.ymlにサービス定義があります。
php-fpm:
container_name: professionalworks
build:
context: .
dockerfile: ./docker/php/Dockerfile
env_file: .env
volumes:
- .:/var/www/html:delegated
- ./vendor/:/var/www/html/vendor:delegated
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini
depends_on:
- mariadb
- blackfire
音量設定の場合は、以下があります。
volumes:
mariadb:
php-fpm:
driver: lebokus/bindfs:latest
driver_opts:
sourcePath: "${PWD}"
map: "${UID}/33:@${UID}/@33"
しかし、コンテナには何の効果もありません。フォルダはまだホストユーザーが所有しています。
$ id -u
33
$ stat . # or stat ./vendor
Uid: ( 1000/ UNKNOWN) Gid: ( 1001/ UNKNOWN)
私は内部について何も知らず、読んだことを付け加えなければbindfs
なりません。地図の binfs のマニュアルページ私にインスピレーションを与えませんでした:
--map=user1/user2:@group1/@group2:..., -o map=... Given a mapping user1/user2, all files owned by user1 are shown as owned by user2. When user2 creates files, they are chowned to user1 in the underlying directory. When files are chowned to user2, they are chowned to user1 in the underlying directory. Works similarly for groups. A single user or group may appear no more than once on the left and once on the right of a slash in the list of mappings. Currently, the options --force-user, --force-group, --mirror, --create-for-*, --chown-* and --chgrp-* override the corresponding behavior of this option. Requires mounting as root.
また、3つの異なるフォルダ/ファイルをマウントしたいのですが、ボリュームは次のようになります。
./docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini`
ユーザーはホストからマップされてはいけません。
次の事項のみを守ってください。
./:/var/www/html:delegated
./vendor/:/var/www/html/vendor:delegated
マップオプションについてさまざまな設定を試しましたが、実際にどのような機能をしているのかわかりません。特に。@
オンラインで見つけたいくつかの礼儀のシンボルは私を本当に混乱させました。
例えば公式Dockerの作成例使用:
driver_opts:
sourcePath: "${PWD}"
map: "${UID}/0:@${UID}/@0"
ユーザー使用:
driver_opts:
sourcePath: "${PWD}/../clients-service"
map: "${UID:-1000}/33:@${UID:-1000}/@33"
の意味は何ですか@
?なぜ使用すべきですか-1000
?
最も重要なのは、ホストのボリュームをどのようにバインドし、コンテナ内のコンテナユーザーにマッピングするのですか?理想的には双方向で書き込みが可能です。つまり、ホストで生成されたファイルをコンテナ内で編集できる必要があり、その逆も同様です。できますか?それでは、これを達成するために何を使用できますかlebokus/docker-volume-bindfs plugin
?