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

803
Visualizações
.dockerignore fails to include files in subdirectories with !**/*.extension pattern

I'm having trouble with the .dockerignore file. This is my project structure:

file.sh
file.js
file.go
file.py
subdir/
    file2.go
    file2.py
.dockerignore
Dockerfile

According to the .dockerignore documentation:

(...) you may want to specify which files to include in the context, rather than which to exclude. To achieve this, specify * as the first pattern, followed by one or more ! exception patterns.

And:

Lines starting with ! (exclamation mark) can be used to make exceptions to exclusions.

Finally:

Docker also supports a special wildcard string ** that matches any number of directories (including zero). For example, **/*.go will exclude all files that end with .go that are found in all directories, including the root of the build context.

Based on that, this is my .dockerignore file:

# ignore everything
*

# whitelist
# ---------

# python files
!**/*.py

When I build and run the container and inspect the files, I get this:

file.py

The subdir directory is missing, subdir/file2.pyshould be included. It works if I add !subdir/**/.py to my .dockerignore, but the idea is to include any .py file in any subdirectory.

This is the file structure that should be present in the container:

file.py
subdir/
    file2.py

What's going on here?

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

0

I found a few issues that mention this exact problem, like these:

Exception patterns in .dockerignore do not support wildcard directories dockerignore does not respect the "special wildcard **" (comment)

And it seems like it's not gonna be fixed any time soon :(

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