How to create another /tmp directory, for example, in the same container and give it r/w permissions?
docker-compose.yml:
nginx:
    image: nginx
    ports:
      - 80:80
    volumes:
      - ./volumes/nginx/conf.d:/etc/nginx/conf.d
    command: nginx -g "daemon off;"
    networks:
      - network
                You can create a directory or perform any other action by defining it in a Dockerfile. In the same directory as your docker-compose.yml create a Dockerfile:
touch Dockerfile
Add to your Dockerfile following line:
RUN mkdir /tmp2
RUN chmod 755 /tmp2
to the docker-compose.yaml add build information:
nginx:
      image: nginx
      build: .
      ports:
        - 80:80
      volumes:
        - ./volumes/nginx/conf.d:/etc/nginx/conf.d
      command: nginx -g "daemon off;"
      networks:
        - network
                        Simply just add a volume with the directory you wish to create and it would be created automatically during startup
nginx:
    image: nginx
    ports:
      - 80:80
    volumes:
      - ./volumes/nginx/conf.d:/etc/nginx/conf.d
      - ./volumes/hosted-direcotry/hosted-sub-direcotry:/etc/created-direcotry/created-sub-directory/
    command: nginx -g "daemon off;"
    networks:
      - network
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With