Docker Community Forums

Share and learn in the Docker community.

Yml config volume wipes out container files

Hello,

i’ve read some posts online and the way how it works i’ve seen that ppl say that if you want to example share a folder host<=>container if the host folder is empty the data of folder in container will be available to access from host folder.

if host folder is not empty then all files what are in host folder will be send to container folder (removing everything what’s into container folder)

however i created a simple image and into it i created a folder + file for test /dope/dope.txt

now i created my docker-compose yml file

version: '3.7'
services:
  nginx:
    container_name: nginx
    ports:
     - "0.0.0.0:80:80"
     - "0.0.0.0:443:443"
    image: "theraw/the-world-is-yours:testb"
    shm_size: '512MB'
    privileged: true
    restart: unless-stopped
    networks:
      nginx_net:
        ipv4_address: 172.69.0.70
    dns:
     - "1.1.1.1"
     - "1.1.0.0"
    ulimits:
     nproc: 65535
    cap_add:
     - "CAP_SYS_RESOURCE"
     - "CAP_SYS_TIME"
    volumes:
       - /dope:/dope

networks:
  nginx_net:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 172.69.0.0/16

the /dope folder doesn’t even exist on host however after docker-compose -f build.yml up -d it will be created and will be empty also dope.txt file on container will be deleted

Can someone please tell me what i’m doing wrong because i’m creating a scaleable app and it will be used for public not just for myself and i really need to know what’s wrong here…

What i want to do is after someone creates a container (with same yml file i posted) and the image that i’ve created they will be able to access /nginx/ folder from their host so ppl can change nginx configs from host without needing to login on container, however i created my image before and after docker-compose i ended up lossing all /nginx/ folder and config files so i tried again with the /dope/ folder test and same thing happend…

Thank you