Docker Community Forums

Share and learn in the Docker community.

Nginx container doesn’t copy files to my host

I am trying to copy a set of files (etc/nginx/*) from Nginx container to myhost (./nginx) but don’t work.
Every time I run my docker-compose, the folder on the host (/ usr / development / nginx) is empty. How can I do this?

Environment

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"

Docker Compose

docker-compose version 1.25.5, build 8a1c60f6

Docker

Docker version 19.03.6, build 369ce74a3c

My docker-compose.yml

version: '3.7'

    services:
      nginx:
        container_name: 'nginx'
        hostname: nginx
        image: nginx
        ports:
          - "80:80"
          - "443:443"
        restart: unless-stopped
        command: /bin/sh -c "while :; do sleep 6h & wait ${!}; nginx -s reload; done & nginx -g 'daemon off;'"
        volumes:
          - ./nginx:/etc/nginx
          - ./certbot/conf:/etc/letsencrypt
          - ./certbot/www:/var/www/certbot
        networks:
          - docker-network
      portainer:
        image: portainer/portainer
        container_name: portainer
        hostname: portainer
        ports:
         - 9000:9000
        volumes:
         - /var/run/docker.sock:/var/run/docker.sock
         - ./portainer/data:/data
        networks:
          - docker-network

      certbot:
        container_name: 'certbot'
        hostname: certbot
        image: certbot/certbot
        volumes:
          - ./certbot/conf:/etc/letsencrypt
          - ./certbot/www:/var/www/certbot
        restart: unless-stopped
        entrypoint: /bin/sh -c "trap exit TERM; while :; do certbot renew; sleep 12h & wait ${!}; done;"
        depends_on:
          - nginx
        networks:
          - docker-network
    networks:
      docker-network:
        name: docker-network
        driver: bridge

So the problem isn’t on the build end. This is probably an issue with docker itself. I managed to resolve the problem by removing the container and running docker system prune, which removed the cached images. Still odd that it appeared to be up to date, yet wasn’t actually.