A
A
Alexey Nikolaev2019-08-21 17:13:50
Docker
Alexey Nikolaev, 2019-08-21 17:13:50

How to do livereload for php in Docker?

Good day.
It's no secret that the main disadvantage of docker is the inconvenience of development: every time after changing files, you have to do docker cp in order to copy the changes to the container. However, volume would seem to provide the ability to link a directory in a container to a directory on the host machine.

FROM php:7.2.19-apache

VOLUME data /var/www/html
COPY data /var/www/html

# все остальные команды

The folder structure is like this:
- Dockerfile
- config
- data
-- app

After starting the container, I expect Docker to automatically update the corresponding directory (map "data" to "var/www/html", that is, analogous to "COPY data /var/www/html", that is, analogous to volume ./data:/var /www/html in docker-compose). However, this does not happen. I change the files, but the version in the container remains the same.
What did I do wrong, or is this how it should work? If so, is it possible to have docker automatically update directories on file changes on disk?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2019-08-21
@Heian

VOLUME is not analogous to the -v switch when starting a container or volume ./data:/var/www/html in docker-compose. It simply creates a disk storage for the container and maps it to /var/lib/docker/volumes.
To mount a local directory, you still need to use the -v switch for docker or the equivalent in docker-compose.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question