简体   繁体   中英

Docker-compose volume starting empty in container

I have the following docker-compose.yml configuration:

version: '3'

services:
  proxy:
    image: nginx:latest
    container_name: webproxy
    ports:
      - "80:80"
    volumes:
      - /etc/nginx/sites-available:/etc/nginx/sites-available

On my host machine I have a nginx.conf file at /etc/nginx/sites-available/nginx.conf .

Steps:

  1. Start the container with docker-compose -up
  2. Go into the command line of the container with sudo docker exec -it 687 /bin/bash
  3. cd into /etc/nginx/sites-available

Unfortunately the folder in step 3 is empty. My nginx.conf file is not being copied. Is my docker-compose file not configured properly, or are volumes not supposed to also copy and start with the host data?

Doesn't looks anything wrong in docker-compose.yaml , because I used the same file as mentioned by you to create docker container. It worked for me. check your content inside /etc/nginx/sites-available on your host machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM