Nginx容器不会将文件复制到我的主机

时间:2020-06-18 02:42:28

标签: docker nginx docker-compose nginx-reverse-proxy

我正在尝试将一组文件(etc / nginx / *)从Nginx容器复制到myhost(./nginx),但是不起作用。
每次我运行docker-compose时,主机上的文件夹(/ usr / development / nginx)为空。 我该怎么办?

环境

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

我的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

0 个答案:

没有答案