Skip to content

How to create docker media volume shared with host under production mode? #3691

Answered by xjlin0
xjlin0 asked this question in Q&A
Discussion options

You must be logged in to vote

Just found away to answer my own question.

Since my system will allow users to upload their media files, it need to mount the volume read+write with the correct owner. Previously the user was wrongly as systemd-resolve, which can be corrected by the following user setting in production.yml:

services:
  django: &django
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    image: attendees_production_django
    container_name: django
    depends_on:
      - postgres
      - redis
    user: "1001"      #### web user id ####
    volumes:
      - .:/app:z

Everything works now as the uploaded media are in the host's volume with the correct owner, rather than …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ashermatsh
Comment options

@xjlin0
Comment options

Answer selected by xjlin0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants