Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Issues with current folder references #6

Closed
tarunlalwani opened this issue Aug 27, 2015 · 5 comments
Closed

Issues with current folder references #6

tarunlalwani opened this issue Aug 27, 2015 · 5 comments

Comments

@tarunlalwani
Copy link
Contributor

I have a docker-compose.yml which refers to the folders in current directory

base:
  image: centos:6.6
  entrypoint: /bin/bash
  volumes:
    - ./scripts:/scripts
  command: /scripts/infinite.sh

The file is there in the ./scripts folder but your API doesn't bring it up fine and I get an error that infinite.sh file is not there. Since you are running it in a docker-container I believe the mapping doesn't happen properly

@francescou
Copy link
Owner

Hi,
I managed to reproduce the issue. The problem occurs when you mount a volume by its relative path, if you write the full path of the folder it works, e.g. /opt/docker-compose-projects/my-awesome-project/scripts/.

However, I will make further investigation to fix the application to support relative paths.

@tarunlalwani
Copy link
Contributor Author

For now I moved the server out of docker to fix the issue as I have delivery of a project dependent on this. There are some caveats that needs to be worked out.

if we map a folder like ../scripts then it would point to your /opt/scripts, now if I map the folder while running docker-compose-ui, then on first time the mapping won't work. But if I restart the container using docker client it works. So some different type of use cases needed to checked out around this area

@francescou
Copy link
Owner

I've made several tests, I came to the conclusion that the problem is caused by Compose itself while running inside a container.

I've tried to mount a volume with docker-compose inside a container based on the official centos image and then another one based on dduportal/docker-compose. In both cases I didn't manage to mount a volume.

I've also found some information about the problem on the following links: dduportal/docker-compose/#volumes-relative-and-absolute (check also the workaround suggested by kayvan in the comments) and https://github.com/dduportal/dockerfiles/issues/5

I will close the issue, feel free to reopen if necessary.

@twhtanghk
Copy link

My solution is to define environment variable "COMPOSEDIR" on compuse ui docker-compose.yml as follows:

version: '2'
services:
  composeui:
    image: francescou/docker-compose-ui
    container_name: composeui
    environment:
      - GIT_REPO=https://github.com/francescou/docker-compose-ui.git
      - COMPOSEROOT=/home/user/git/docker.shell
    ports:
      - 5000:5000
    volumes:
      - ..:/opt/docker-compose-projects
      - /var/run/docker.sock:/var/run/docker.sock

The volume relative to the directory defined in "COMPOSEROOT" can then be referenced in the docker-compose.yml of other service (e.g. ovs) as follows:

version: '2'
services:
  ovs:
    image: socketplane/openvswitch
    container_name: ovs
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    volumes:
      - /lib/modules:/lib/modules
      - ${COMPOSEROOT}/ovs:/root
    network_mode: host

I also tried to replace the variable name "COMPOSEROOT" with "PWD". It seems fine. For your info.

@francescou
Copy link
Owner

Hi Tommy, it seems a good solution

thanks for your contribution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants