@wahyu_sumartha_priya Yes, you are correct. Docker Desktop for Mac runs Docker inside a lightweight virtual machine (VM) to provide the Docker runtime environment on macOS. Because of this design, you can’t directly access the mountpoint directory on the Docker host from macOS.
In this case, to update the file within the Docker volume while using Docker Desktop for Mac, you have a few options:
-
Update the File Inside the Container: Instead of updating the file on the Docker host and copying it to the volume, you can access the container directly and update the file inside the container. You can use the docker exec
command to access a running container and edit the file using a command-line text editor like vi
or nano
. For example:
docker exec -it <container_name_or_id> vi /code/app.py
This command will open the app.py
file inside the container using the vi
editor, allowing you to make changes directly.
-
Use Docker Bind Mounts: Instead of using volumes, you can use bind mounts to map a directory on your host system (macOS) directly into the container. With bind mounts, changes made on the host are immediately reflected inside the container, bypassing the need to copy files to volumes. You can modify your docker-compose.yml
file to use bind mounts instead of volumes. For example:
services:
web-fe:
<Snip>
volumes:
- ~/counter-app:/code
This configuration will mount the ~/counter-app
directory on your macOS host into the /code
directory inside the container.
Choose the method that best fits your workflow and environment. If you have any further questions or need assistance, feel free to ask!