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

143
Visualizações
How do I copy a directory from one container to another container in Docker Compose?

I have two docker-compose services nginx and django, and in my command shell script I perform a gulp task which builds my static files. After the build process is complete, I want to perform a copy command to copy those files to the nginx container, but I'm not sure what command to use.

docker-compose.yml

django:
  build:
    context: .
    dockerfile: ./compose/django/Dockerfile
  user: django
  depends_on:
    - postgres
    - redis
  command: /gunicorn.sh
  env_file: .env

nginx:
  build: ./compose/nginx
  depends_on:
    - django

  ports:
    - "0.0.0.0:80:80"

gunicorn.sh

#!/bin/sh
gulp build
python manage.py migrate
/usr/local/bin/gunicorn config.wsgi -w 4 -b 0.0.0.0:5000 --chdir=/app

I'm guessing I could use scp within gunicorn.sh, but i'm not sure how I would reference the nginx service's IP address.

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

0

Just share volumes between containers, there is no need to actually copy the files.

There are multiple ways to define the volumes, but I suppose you don't want these files to be on your host file system.

Try something like the following:

volumes:
  - static:

django:
  build:
    context: .
    dockerfile: ./compose/django/Dockerfile
  user: django
  depends_on:
    - postgres
    - redis
  command: /gunicorn.sh
  volumes:
    - static:/path/to/your/static/files
  env_file: .env

nginx:
  build: ./compose/nginx
  depends_on:
    - django
  volumes:
    - static:/some/dir/to/serve/files/from/
  ports:
    - "0.0.0.0:80:80"

And then configure nginx to serve your static files from /some/dir/to/serve/files/from/.

about 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