fatihach
(Fatihach)
May 17, 2023, 12:29pm
1
hi
I want to mount a file logstash in volume
I use this configuration in docker-compose file :
volumes:
- type: bind
source: ./logstash.conf/
target: /usr/share/logstash/pipeline/logstash.conf
but the logstash mounted as a directory not as a file
I work on windows 11
what is the problem ?
meyay
(Metin Y.)
May 17, 2023, 6:54pm
2
fatihach:
source: ./logstash.conf/
If the source path ends with a slash or actually is a folder, then a folder will be mounted. Try without the trailing slash.
1 Like
fatihach
(Fatihach)
May 17, 2023, 9:08pm
3
I delete the slash but the logstash is mounted as a folder not as a file
meyay
(Metin Y.)
May 18, 2023, 8:28am
4
I just tested it without docker-compose in a powershell terminal on Windows 11/Docker Desktop 4.19:
date > date.txt
docker run --rm -ti -v "${pwd}\date.txt:/date.txt" alpine cat /date.txt
# output:
# Donnerstag, 18. Mai 2023 09:55:59
The container binds the single file and renders the ouput in the terminal.
Then I tried it with following compose file (in the same folder where date.txt already exists)
services:
bind:
image: alpine:latest
volumes:
- type: bind
source: ./date.txt
target: /date.txt
command: cat /date.txt
Then run it:
docker compose -p test up
#output
#[+] Running 2/2
# - Network test_default Created 0.0s
# - Container test-bind-1 Created 0.1s
#Attaching to test-bind-1
#test-bind-1 |
#test-bind-1 | Donnerstag, 18. Mai 2023 09:55:59
#test-bind-1 |
#test-bind-1 exited with code 0
It works as expected.
1 Like
rimelek
(Ákos Takács)
May 18, 2023, 5:55pm
5
Check the files on the host and make sure you are using the correct filename and logstash.conf
is not already a folder on the host. Bind mounting with the long syntax should not create a host path unless create_host_path
was set to true, but I remember that it happened to me before so some years ago with an older compose version.
I use Docker Desktop for Mac and it works as @meyay described.