开发者

All file in folder is missing when docker-compse up?

I now i using github and docker. inside the git repository include many docx and xlsx files in "app/media". When i push and pull docker image.i try to docker-compose exec -it web bash to access for inspect i see the files in 'app/media' is all missing and media folder in host is blank. How i can to solve this?

version: '3.8'

services:
  web:
    image: xxxx/myimage:latest
    command: gunicorn  --workers=3 --threads=2 --worker-connections=3000 --timeout 300  project.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - ./static:/usr/src/app/static
      - ./media:/usr/src/app/media
    ports:
      - 8000:8000
    env_file:
      - ./.env
    depends_on:
      - db
  db:
    image: postgres:13.0-alpine
    restart: always
    volumes:
      - ./database:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER=${SQL_USER}
      - POSTGRES_PASSWORD=${SQL_PASSWORD}
      - POSTGRES_DB=${SQL_DATABASE}
    ports:
      - 5432:5432
  nginx:
      image: nginx:1.13.0-alpine
      container_name: wrk-nginx
      restart: always
      ports: 
        - "80:80"
        - "443:443"
      volumes:
        - ./nginx.conf:/etc/nginx/conf.d/default.conf     
        - ./static:/home/app/web/static
        - ./media:/home/app/web/media 
        - ./certbot/conf/:/etc/nginx/ssl/:ro
      depends_on:
  开发者_开发技巧      - web
  certbot:
    image: certbot/certbot:latest
    volumes:
      - ./certbot/conf/:/etc/letsencrypt/:rw

  pgbackups:
      container_name: Backup
      image: prodrigestivill/postgres-backup-local
      restart: always
      volumes:
        - /home/myuser/database:/backups
      links:
        - db:db
      depends_on:
        - db
      environment:
        - POSTGRES_HOST=db
        - POSTGRES_DB=${SQL_DATABASE} 
        - POSTGRES_USER=${SQL_USER}
        - POSTGRES_PASSWORD=${SQL_PASSWORD}
        - POSTGRES_EXTRA_OPTS=-Z9 --schema=public --blobs
        - SCHEDULE=@every 0h30m00s
        - BACKUP_KEEP_DAYS=7
        - BACKUP_KEEP_WEEKS=4
        - BACKUP_KEEP_MONTHS=6
        - HEALTHCHECK_PORT=81


It's just a guess because it's hard to figure out what is happening here without having the full project.

When bind-mounting a directory from the host in a container (this what is done here), files and directories maintain the permissions and the ownership they have on the host.

Often the problem comes from the ownership. You should check the ownership of the directories / files on the host and the default user (UID/GID) of the container. This default user need to have the required permission (group or user) to see the directories and files on the host.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜