I wanna copy new static files from Docker container via named volume to nginx
container that has old static.
Prerequisites:
Host machine directory tree:
.
├── data
│ ├── bar.2.css
│ └── foo.2.js
├── docker-compose.yml
├── Dockerfile
Dockerfile:
FROM busybox:latest
COPY data /data
docker-compose.yml:
version: '3'
services:
static:
image: 'myimage'
volumes:
- 'myvolume:/data'
nginx:
image: 'nginx'
volumes:
- 'myvolume:/data'
volumes:
myvolume:
Directory tree of named volume myvolume with old static:
.
├── bar.1.css
└── foo.1.js
Sequence of steps:
-
Build
myimage
with Dockerfile:docker build -t myimage .
-
Check new static files in
myimage
:docker run myimage ls /data
bar.2.css
foo.2.js -
Run:
docker-compose up -d --build static
In my mind it must rebuild service static
and overwrite old static files. But it did’t. Why and how to fix it? Also, what is a better approach?