One method for transferring an editable folder to a Docker-compose service without any impact on the host device is to use a Docker volume. The steps are as follows:
Create a directory on the host that you want to share with the container. For example, create a directory called "mydata" in your home directory.
Modify your Docker-compose file to add a new volume definition for the directory:
version: "3"
services:
my_service:
image: my_image
volumes:
- ./mydata:/data
This will mount the "mydata" directory on the host to the "/data" directory in the container.
docker-compose up -d
This will start the container with the mounted volume.
Edit the files in the "mydata" directory on the host. The changes will be immediately visible in the container.
When you are done editing, stop the container:
docker-compose down
The changes will be preserved in the "mydata" directory on the host.
Using this method, you can transfer an editable folder to a Docker-compose service without impacting the host device. The changes made in the container will not affect the original files on the host.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-11 13:45:24 +0000
Seen: 9 times
Last updated: Jul 11 '23
How do I create a subdomain on Ubuntu 18x's Apache2 while ensuring that it forwards to HTTPS?
How can I search multiple databases on the local host?
How can the issue "host not found in upstream" be resolved in Docker Networking with nginx?
If I have the Github student developer pack, can I utilize Heroku to host my Django web app?
What are the possible situations in which microservices can fail?