Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

352
Vistas
How to copy contents of folder to /app via dockerfile?

We have a solution-wide folder that contains shared settings that each project needs.

I'm trying to copy the contents of that folder to the /app folder but it's not working

This is part of my dockerfile configuration:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.12 AS build

### this is where I'm trying to copy the contents of Shared Settings to /app
WORKDIR '/src/Shared Settings'
COPY '/src/Shared Settings' /app

### this is part of the rest of the docker file, which works fine
WORKDIR /src
COPY . .
WORKDIR /src/OurProject.Server
RUN dotnet restore OurProject.Server.csproj
RUN dotnet build OurProject.Server.csproj -c Release -o /app

What do I need to change to get the contents of Shared Settings copied to the /app folder in my docker container?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

The Dockerfile documentation for the COPY directive notes that it has two forms, a space-separated form and a JSON-array form, and it notes

This latter [JSON array] form is required for paths containing whitespace.

So applying that to your specific path, you would get

COPY ["src/Shared Settings", "/app"]

This is broadly true in a Dockerfile in general: the only quoting in native Dockerfile syntax is to write things in a JSON array. Wrapping a WORKDIR or a COPY command in single quotes isn't documented as having an effect. A string-form RUN or CMD is an apparent exception to this, but only because these commands are run via a shell and there the shell's quoting rules apply.

over 4 years ago · Santiago Trujillo Denunciar

0

The COPY '/src/Shared Settings' /app command would fail because it is meant for copying from the build context (folder containing your Dockerfile). However, the path '/src/Shared Settings' suggests that you are building from the root directory of your host. If that src directory is not at the root /, but instead exists within a different folder (e.g. /path/to/your/folder_containing_src_and_Dockerfile/src) you should change the instruction in your Dockerfile to:

COPY 'src/Shared Settings' /app

This removes the leading / that causes confusion in the path for your command.

EDIT: if you are building from the src directory, just use the following instruction in your Dockerfile:

COPY 'Shared Settings' /app
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda