这就是我所拥有的:
version: "3.7"
services:
php:
build:
context: .
dockerfile: docker/php.docker
links:
- mariadb
env_file: .env
volumes:
- type: volume
source: webpack_assets
target: /srv/myproject/.webpack
read_only: true
- type: volume
target: /srv/myproject/storage
consistency: delegated
- type: tmpfs
target: /srv/myproject/bootstrap/cache
consistency: delegated
- type: bind
source: .
target: /srv/myproject
read_only: true
consistency: cached
working_dir: '/srv/myproject'
webpack:
image: node:lts
ports:
- '8081:8081'
env_file: .env
volumes:
- type: volume
source: webpack_assets
target: /srv/myproject/.webpack
- type: bind
source: .
target: /srv/myproject
read_only: true
consistency: cached
working_dir: '/srv/myproject'
command: sh -c 'yarn && exec node --max_old_space_size=8192 node_modules/.bin/webpack-dev-server'
volumes:
webpack_assets:
webpack
需要对我的项目文件具有只读访问权限,并且需要写入一个特殊文件webpack-assets.json
,该文件已移至.webpack
目录下,因为我认为您不可以挂载单个文件。
php
需要对此生成文件具有只读访问权限。我希望将其设置为tmpfs
卷,但是显然不能共享?主机系统不需要访问此文件。
问题是当我尝试以这种方式挂载卷时出现此错误:
ERROR: for myproject_webpack_1 Cannot start service webpack: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged\\\" at \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697cRecreating myproject_php_1 ... error
ERROR: for myproject_php_1 Cannot start service php: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged\\\" at \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack: read-only file system\\\"\"": unknown
ERROR: for webpack Cannot start service webpack: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged\\\" at \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged/srv/myproject/.webpack: read-only file system\\\"\"": unknown
ERROR: for php Cannot start service php: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged\\\" at \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack: read-only file system\\\"\"": unknown
如何使它正常工作?