Bogdan Daniel
Bogdan Daniel

Reputation: 2759

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?

Upvotes: 0

Views: 317

Answers (1)

Vishal Vishwakarma
Vishal Vishwakarma

Reputation: 139

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.

Upvotes: 1

Related Questions