Volumes vs Copying in docker containers – a note

I was wondering why a container would not build unless I included a copy command first. I mean – I had a volume set up! That should give the container what it needs to build right? Nope here is the difference:

In Docker, volumes are used for persisting data at runtime, but they’re not available during the build process. If you need files during the build, use the COPY command in your Dockerfile. For instance, to access a .csproj file during a dotnet restore, you’ll need to copy it into the Docker image using COPY *.csproj ./ before running dotnet restore.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *