Compose: Docker machine remote working directory

Created on 9 Mar 2017  路  3Comments  路  Source: docker/compose

I'm not sure this is a docker-machine or docker-compose issue, but will try to explain it.

I have to following compose file:

services:
    db:
      image: postgres
      volumes:
          - .pgdata:/var/lib/postgresql/data
   .... more services...

I run docker-compose and and docker-machine the commands from my laptop.
The local laptop user is goetas and the folder where is stored the application on my laptop is /home/goetas/projects/events.

When running:

eval $($docker machine env my-machine)
docker-compose up

On the remote hosts (my-machine) the container is created, and the a folder /home/goetas/events/.pgdata has been created (to store the database data).

No user goetas has been created on the remote host, only a folder.
From what I could guess, the naming strategy is /home/[LOCAL-USER]/[LOCAL-FOLDER-NAME].

My question is: Is there a way to configure the folder that is used as working directory when running the container?

Most helpful comment

I've created the same issue on docker-machine repo (https://github.com/docker/machine/issues/4020) since is not yet clear to me which application is responsible for this behavior.

I'm not trying to share data between my laptop and the remote host.

What I have is that I deploy the same application from two different laptops (having obviously different user names and having my code stored in different folders), and the result of the deploy is different.

Laptop 1:

  • user: goetas
  • project folder: /home/goetas/projects/events
  • app deployed on the remote host to: /home/goetas/events

Laptop 2:

  • user: admin
  • project folder: /home/admin/proj/events-git-repo
  • app deployed on the remote host to: /home/admin/events-git-repo

Having the app deployed to different folders, depending on local factors is a bit confusing.

As solution i had to hardcode paths into the docker-compose.yml file, but also this sounds not as an optimal solution.

All 3 comments

Shared folders are created to share data between your laptop's filesystem and the virtual-machine using the same absolute paths. That's normal behavior and the only way you're able to mount volumes inside docker-machine.

I don't understand what the problem is.

I've created the same issue on docker-machine repo (https://github.com/docker/machine/issues/4020) since is not yet clear to me which application is responsible for this behavior.

I'm not trying to share data between my laptop and the remote host.

What I have is that I deploy the same application from two different laptops (having obviously different user names and having my code stored in different folders), and the result of the deploy is different.

Laptop 1:

  • user: goetas
  • project folder: /home/goetas/projects/events
  • app deployed on the remote host to: /home/goetas/events

Laptop 2:

  • user: admin
  • project folder: /home/admin/proj/events-git-repo
  • app deployed on the remote host to: /home/admin/events-git-repo

Having the app deployed to different folders, depending on local factors is a bit confusing.

As solution i had to hardcode paths into the docker-compose.yml file, but also this sounds not as an optimal solution.

I've realized that using named volumes is a way better solution than relative or absolute paths. With named volumes this issue does not exists

Was this page helpful?
0 / 5 - 0 ratings