Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!