Sharing files between two containers

Refresh

April 2019

Views

208 time

1

For couple of hours I am struggling with docker compose. I am building angular app. And I could see the files in the dist directory. Now I want to share these files with the nginx container. I thought the shared volume will do it. But when I add

services:
    client:
       volumes: 
            - static:/app/client/dist
    nginx:
          volumes: 
            - static:share/user/nginx/html

volumes:
   static:

an try docker-compose up --build I got this error

client_1  | EBUSY: resource busy or locked, rmdir '/app/client/dist'
client_1  | Error: EBUSY: resource busy or locked, rmdir '/app/client/dist'
client_1  |     at Object.fs.rmdirSync (fs.js:863:18)
client_1  |     at rmdirSync (/app/client/node_modules/fs-extra/lib/remove/rimraf.js:276:13)
client_1  |     at Object.rimrafSync [as removeSync] (/app/client/node_modules/fs-extra/lib/remove/rimraf.js:252:7)
client_1  |     at Class.run (/app/client/node_modules/@angular/cli/tasks/build.js:29:16)
client_1  |     at Class.run (/app/client/node_modules/@angular/cli/commands/build.js:250:40)
client_1  |     at resolve (/app/client/node_modules/@angular/cli/ember-cli/lib/models/command.js:261:20)
client_1  |     at new Promise (<anonymous>)
client_1  |     at Class.validateAndRun (/app/client/node_modules/@angular/cli/ember-cli/lib/models/command.js:240:12)
client_1  |     at Promise.resolve.then.then (/app/client/node_modules/@angular/cli/ember-cli/lib/cli/cli.js:140:24)
client_1  |     at <anonymous>
client_1  | npm ERR! code ELIFECYCLE
client_1  | npm ERR! errno 1
client_1  | npm ERR! [email protected] build: `ng build --prod`
client_1  | npm ERR! Exit status 1
client_1  | npm ERR! 
client_1  | npm ERR! Failed at the [email protected] build-prod script.
client_1  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Any help is fully appreciated

1 answers

1

You can try to solve it without using named volumes:

services:
    client:
       volumes: 
            - ./static-content:client/app/dist
    nginx:
          volumes: 
            - ./static-content:share/user/nginx/html