I would like to shared files from one service to an other. I make a short exemple.
docker-compose.yml
version: "3.7"
services:
web:
build: ./web
depends_on:
- mobile
volumes:
- data-volume:/var/lib/shared
mobile:
build: ./mobile
volumes:
- data-volume:/var/lib/shared
volumes:
data-volume:
Dockerfile.yml (mobile)
FROM node:alpine AS mobile
COPY app.apk /var/lib/shared
RUN ls /var/lib/shared
Dockerfile.yml (web)
FROM node:alpine AS web
RUN ls /var/lib/shared
So I want to see app.apk from mobile service in web service.
I try to use volumes in docker-compose but it's not working. I have tried to figure out for hours.
Someone know how to do that ?
the dockerfile is executed first. The compose-file then overrides the shared folder. You can't access volumes in dockerfiles.
app.apk
gets copied into the docker-image./var/lib/shared
.solution: copy the app into the volume after starting the container.
using docker exec -it <container_name> bash
you can start a shell in the container after it has started. You can find the name with docker ps
.