Ask Your Question
1

What is the method for transferring an editable folder to a docker-compose service without any impact on the host device?

asked 2023-07-11 13:45:24 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-07-11 14:03:02 +0000

qstack gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2023-07-11 13:45:24 +0000

Seen: 9 times

Last updated: Jul 11 '23