Container files not updated when changed from the host mapped volume

Juliano Nunes Silva Oliveira

I have the following docker-compose.yml:

version: '3'

services:
  web:
    build: 
      context: .
      dockerfile: ./.docker/node.dockerfile
    volumes:
      - D:\Proj\Web:/app
    ports:
      - '3000:3000'
    depends_on: 
      - 'db'
    networks:
      - holder-network
    restart: on-failure
    tty: true


  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - holder-network
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: P@ssw0rd
      MYSQL_DATABASE: holder_db
      MYSQL_USER: holder_usr
      MYSQL_PASSWORD: P@ssw0rd


networks:
  holder-network:
    driver: bridge

volumes:
  db_data:

And the node.dockerfile:

FROM node:7.10

MAINTAINER Juliano Nunes

RUN mkdir /var/www

RUN npm install nodemon -g

WORKDIR /var/www

ADD . /var/www

RUN npm install

CMD nodemon

I'm changing the files under D:\Proj\Web from the host, however it doesn't update the files in the container. Why?

Juliano Nunes Silva Oliveira

I've found the error. My docker-compose.yml was using /app as the path and node.dockerfile was using /var/www.

Here's the updated (working) version:

version: '3'

services:
  web:
    build: 
      context: .
      dockerfile: ./.docker/node.dockerfile
    volumes:
      - D:\Proj\Web:/var/www
    ports:
      - '3000:3000'
    depends_on: 
      - 'db'
    networks:
      - holder-network
    restart: on-failure
    tty: true


  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - holder-network
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: P@ssw0rd
      MYSQL_DATABASE: holder_db
      MYSQL_USER: holder_usr
      MYSQL_PASSWORD: P@ssw0rd


networks:
  holder-network:
    driver: bridge

volumes:
  db_data:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Hot reload fails when files are changed from the host mapped volume in Docker-compose

How to find volume files from host while inside docker container?

Docker volume updated on container after changes, but nothing happen in host

Replace a file from host to container with mounted volume

How to mount volume from host to container

Share directory or volume with container from host

How to mount volume from container to host in Docker?

Dockerfile COPY from host to container works, but when docker-compose.yml uses volume, the file in container not visible to host

laravel fails to load videos from directory mapped as a volume in a docker container

Docker: prevent container from modifying host's files when binding

Docker COPY error when copying files from host to container

Docker: Files from volume not updated in target

How to get the mapped port on host from a docker container?

Composition: why are "container instance" attributes not updated when "contained instance" are changed?

What happens when a volume links an existing populated host and container dir

Running docker on Ubuntu: mounted host volume is not writable from container

Volume share from container to host docker-compose

How does volume mount from container to host and vice versa work?

Persisting the images from Docker Container to host named volume

dependency container accesses files from dependent container via volume

expose files from docker container to host

Copying files from Docker container to host

Docker: Copying files from Docker container to host

Copying files from host to Docker container

How to copy files from host to Docker container?

Docker - accessing files inside container from host

Copy files from Container to host using Dockerfile

How to volume map a directory inside a volume mapped directory in a container?

Copy files and create symlink from a shared volume on Docker on container start