Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question : my host and container don't see the folder linked by the volume. Is it because of Propagation: rprivate ? #20876

Closed
ghost opened this issue Mar 2, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 2, 2016

Hello,

the root of the problem is that I am trying to use a ssh key in a docker container (gocd-server) to be able to pull source code from a private git repository.

Now, if I understand correctly, I need to create a volume where I put my ssh keys and config file but the folder created is not shared between my container and my host. It only works if I copy the key inside my container and pull but if I restart the container, the setup is gone and I need to do it again.

I can see that my container is writing on my host for a few volumes but not for others.
For example, ./gocd/config (host) and /etc/go (container)

*host : *
[20:23:07 - gillouche@arch:~/data/docker/gocd/config]$ ll
total 92K
-rw-r--r-- 1 go go 2.5K Mar 2 06:22 agentkeystore
-rw-r--r-- 1 go go 16 Mar 2 06:22 cipher
-rw-r--r-- 1 go go 992 Mar 2 06:22 config.properties
-rw-r--r-- 1 go go 304 Mar 2 20:08 cruise-config.xml
-rw-r--r-- 1 go go 967 Mar 2 06:22 cruise-config.xml.2016-03-02-05-23-01
-rw-r--r-- 1 go go 45K Mar 2 20:08 cruise-config.xsd
-rw-r--r-- 1 go go 607 Mar 2 06:23 gadget_truststore.jks
-rw-r--r-- 1 go go 799 Mar 2 06:22 go_update_server.pub
-rw-r--r-- 1 go go 3.8K Mar 2 06:22 jetty.xml
-rw-r--r-- 1 go go 1.5K Mar 2 06:22 keystore
-rw-r--r-- 1 go go 1.9K Mar 2 20:08 log4j.properties
-rw-r--r-- 1 go go 2.4K Mar 2 06:22 truststore

(I never wrote any of those files, they were written by the container)
container
root@746df548519b:/etc/go# ls -l
total 4
-rw------- 1 go go 1890 Feb 16 16:27 log4j.properties

I am using a docker-compose file and all my docker containers config/folders etc are in the same folder called docker.

Here is my configurations :

Docker compose file
gocd-server:
container_name: gocd-server
image: gocd-server-test
ports:
- "18153:8153"
- "18154:8154"
volumes:
- ./gocd/db:/var/lib/go-server/db/h2db
- ./gocd/plugins:/var/lib/go-server/plugins/external
- ./gocd/flyweight:/var/lib/go-server/pipelines/flyweight
- ./gocd/config:/etc/go
- ./gocd/ssh:/var/go/.ssh
- ./gocd/artifacts:/var/lib/go-server/artifacts

Here is the *_docker inspect *_of the running container

http://pastebin.com/CkXRjfu1

Here is the dockerfile I used to create my gocd image

http://pastebin.com/yLq2CpfN

**Output of docker version**:

Client:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Thu Feb 25 09:29:05 2016
OS/Arch: linux/amd64

Server:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Thu Feb 25 09:29:05 2016
OS/Arch: linux/amd64

Output of **docker info**:

Containers: 13
Running: 4
Paused: 0
Stopped: 9
Images: 28
Server Version: 1.10.2
Storage Driver: devicemapper
Pool Name: docker-8:3-6684765-pool
Pool Blocksize: 65.54 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 3.148 GB
Data Space Total: 107.4 GB
Data Space Available: 104.2 GB
Metadata Space Used: 5.943 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.142 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Either use --storage-opt dm.thinpooldev or use --storage-opt dm.no_warn_on_loop_devices=true to suppress this warning.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.115 (2016-01-25)
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 4.4.1-2-ARCH
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.61 GiB
Name: arch
ID: BNDD:6TTK:C7YZ:HG7K:FQQT:MQLA:MVQL:2Q57:F6BU:F4BB:ZQVT:PCQS

Provide additional environment details (AWS, VirtualBox, physical, etc.):
No virtualbox, I am trying on my host first before moving everything to a synology NAS.

Describe the results you received:
My container and my hosts don't see the changes on the volume.

Describe the results you expected:
Be able to create file on the host folder and the container can see them.

Provide additional info you think is important:

Thanks.

@ghost
Copy link
Author

ghost commented Mar 4, 2016

Nobody has an idea ? I cannot use docker because of this.

I can't find a way to change the propagation to something other than rprivate (in docker inspect mount flags).

@mlaventure
Copy link
Contributor

Since all the host volume path in your docker compose start with ./ the host directory is mounted instead of a named volume being used.

My docker-compose understanding is still limited unfortunately, so I'll give you a bit more details from a straight docker engine usage.

Any changes you make to the container outside of those bind mounts should stay within the container though, you would only lose them if you were to use --rm as part of your docker run if not, upon a subsequent docker start everything should still be there.

@ghost
Copy link
Author

ghost commented Mar 5, 2016

I am going to read the documentation again I think but volumes are still a mystery at the moment.

If I run this command :
docker run -it -v /mnt/data/docker/gocd/ssh:/var/go/.ssh gocd-server-test bash

I can act on my shared folder and see the changes in my host and container but if I run this one, I can't :

docker run -d -p 8153:8153 -v /mnt/data/docker/gocd/ssh:/var/go/.ssh gocd-server-test

I also tried to put absolute path and not relative in the docker compose and it doesn't work.

Thanks anyway.

@ghost
Copy link
Author

ghost commented Mar 7, 2016

We can close this issue, I misunderstood volumes and the mount command. Now everything works as expected.

@ghost ghost closed this as completed Mar 7, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant