Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

756
Visualizações
Dockerfile: COPY / ADD with space character in path (Windows)

In Windows 10 (cmd) I'm trying to copy a file from a subfolder containing a space character in its name.

  1. First I tried to use quotation marks:

    FROM jfloff/alpine-python:2.7
    COPY "Folder 1/File.txt" "Dir 1"
    

    Error message:

    failed to process "\"Folder": unexpected end of statement while looking for matching double-quote

  2. "JSON" format (skipped the first line):

    COPY ["Folder 1/File.txt" "Dir 1"]
    

    Error message:

    failed to process "[\"Folder": unexpected end of statement while looking for matching double-quote

  3. Trying to escape with a single backslash:

    COPY "Folder\ 1/File.txt" "Dir\ 1"
    

    Error message:

    failed to process "\"Folder\\": unexpected end of statement while looking for matching double-quote

  4. Trying to escape with a double backslash:

    COPY "Folder\\ 1/File.txt" "Dir\\ 1"
    

    Error message:

    failed to process "\"Folder\\\\": unexpected end of statement while looking for matching double-quote

  5. Also tried a suggestion to use %20 instead of space:

    COPY ["Folder%201/File.txt" "Dir%201"]
    

    Error message:

    COPY failed: no source File

  6. Escape character replacement:

    # escape=`
    COPY "Folder` 1/File.txt" "Dir 1"
    

    Error message:

    failed to process "\"Folder`": unexpected end of statement while looking for matching double-quote

  7. The same, but without quotes:

    #escape=`
    COPY Folder` 1/File.txt Dir` 1
    

    Error message:

    COPY failed: stat /var/lib/docker/tmp/docker-builder082039614/Folder: no such file or directory

  8. Method with packing / unpacking using a tar archive (I'm not happy with that idea).

It should be possible, shouldn't it?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Maybe you can use ARG to help you, like this:

Dockerfile:

FROM jfloff/alpine-python:2.7
ARG src="Folder 1/File.txt"
ARG target="Dir 1/"
COPY ${src} ${target}

BTW, a / has to be add at the end of Dir 1 if you treat really want to treat it as a folder.

And, JSON format is also ok, just you miss ,, it should be:

FROM jfloff/alpine-python:2.7
COPY ["Folder 1/File.txt", "Dir 1/"]

Update for your comments:

In official guide, it said:

When copying files or directories that contain special characters (such as [ and ]), you need to escape those paths following the Golang rules to prevent them from being treated as a matching pattern.

So, for your case, it should be:

FROM jfloff/alpine-python:2.7
ARG src="[[]Folder 1]/__SLIM_TEMPLATE.mm"
ARG target="[Folder 1]/"
COPY ${src} ${target}

Or:

FROM jfloff/alpine-python:2.7
COPY ["[[]Folder 1]/__SLIM_TEMPLATE.mm", "[Folder 1]/"]
over 4 years ago · Santiago Trujillo Relatório

0

agree it's annoying to get files from docker that have special characters, had similar experience and after hours of try and errors, I came up with this simple solution that I now use since then.

tar/zip the files and then "docker cp" them easily without having to worry about dozens of []'"..

tar files in your container machine:

zipped

tar czf myfiles.tar.gz file1.txt dir24 file_xyz

or unzipped

tar -cvf myfiles.tar file1.txt dir24 file_xyz

Then copy them to local directories in your windows machine.

open cmd in windows run

docker cp ABCD_CONTAINER_NAME:PATH/myfiles.tar.gz d:/TARGETDIR/

check if files have been transferred in d:/TARGETDIR/

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda