可以通过以下方式在容器之间共享命名卷:
services: nginx: build: ./nginx/ ports: - 80:80 links: - php volumes: - app-volume:location_in_the_container php: build: ./php/ expose: - 9000 volumes: - app-volume:location_in_the_containervolumes: app-volume:
这是我用来更好理解的示例配置。我将从
web容器中生成的静态文件暴露给一个名为的卷
static-content,然后由该
nginx容器读取并提供服务:
services: nginx: container_name: nginx build: ./nginx/ volumes: - static-content:/usr/src/app web: container_name: web env_file: .env volumes: - static-content:/usr/src/app/public environment: - NODE_ENV=production command: npm run packagevolumes: static-content:



