0

Consider the scenario

From package-alpine:latest as package

FROM alpine:latest
COPY --from=package /opt/raw /queue/raw
RUN filter-task /queue/raw --> this will change raw itself

Need a Volume here on queue so that, when I am running I can get the finished raw directly on host.

Wondering if its possible and if yes what is the syntax

Tried with docker volume but that actually make the queue directory empty

docker run -v $HOME/queue:/queue process:latest
Alejandro Galera
  • 3,445
  • 3
  • 24
  • 42
rohit
  • 862
  • 12
  • 26

1 Answers1

0

What you define in your Dockerfile is executed in build-phase (build), not in container-deployment (run) phase.

You're creating volumes in run phase, so, /queue could not still exist.

So, I think you need to execute filter-task from Dockerfile RUN command to docker run command.

Just try with this: Dockerfile

FROM alpine:latest COPY ./filter-task

Create image:

docker build -t process:latest . 

Run container with filter task as entrypoint, not in Dockerfile:

docker run -v /opt/raw:/queue/raw process:latest filter-task /queue/raw

At this point, when container is created, volume is mounted and data stored inside container in /queue/raw will be accesible in /opt/raw in host. Your volume was empty because if you mount a volume that alrealdy exists in container, it's not mounted.

Alejandro Galera
  • 3,445
  • 3
  • 24
  • 42