Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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:

  1. 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.

  2. 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.

  1. Run the Docker-compose command to start the service:
docker-compose up -d

This will start the container with the mounted volume.

  1. Edit the files in the "mydata" directory on the host. The changes will be immediately visible in the container.

  2. 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.