user9022931
user9022931

Reputation:

How to synchronize host folder in container folder with Docker

I would like to know how to synchronize host folder in container folder with Docker.

This is my Dockerfile :

FROM node:carbon

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

CMD [ "npm", "start" ]

I have no docker-compose.yml

Thanks a lot :)

Upvotes: 6

Views: 13493

Answers (2)

Sagar Vaghela
Sagar Vaghela

Reputation: 1263

You have to map volume of your docker container directory with host directory.

For example :

docker run -v <host_dir>:<container_dir> -other options imagename 

Here both directory synchronised vice or versa.

Host directory and container directory must be available.

Upvotes: 13

sanath meti
sanath meti

Reputation: 6537

by mounting volume

docker run -v /host/folder://usr/src/app -it imagename /bash then you can change inside host folder it will reflect in container as well.

Upvotes: 0

Related Questions