1

I've got a curious problem with a rails project in docker that I cannot find a solution for, after 3 days of googling. I did manage to find a couple of issues similar to my problem, on docker specific forums, but they were either for the newer docker or unsolved. It should be noted that I am very limited in my understanding of dockers workings as this is my first project that requires it, also I have inherited this project from another developer who was using a mac with no issues.

The problem is files created "by docker" are not mirrored onto the host working directory.

The strange thing is files edited by docker/rails that already exist update immediately (container to host) eg: running rake db:migrate changed schema.rb file that I had edited manually (which was expected). Any files that are altered by me update fine too (host to docker/rails) I can see changes immediately on refresh.

Wheras if I run say a rails precompile or generate command it states the files have been created and can be seen in the running project but not the windows project directory!

I'm using docker toolbox, boot2docker in virtual box on windows 8 (I cannot use docker for windows). I have made sure the dir the project is in is shared and in User etc. I start my machine and session in the usual way:

docker-machine start > env > eval(...etc)

then

docker-compose up

when the project is up, I ran:

docker exec <containerID> rails generate controller <ControllerName> new edit --no-test-framework

(above taken from a guide, no errors shown)

I refreshed the windows directory and left / reentered it. Nothing added. precomiling assets has the same result.

LOG (second time running above command)

  identical  app/controllers/<<Controller_name>>_controller.rb
       route  get '<<Controller_name>>/edit'
       route  get '<<Controller_name>>/new'
      invoke  erb
       exist    app/views/<<Controller_name>>
   identical    app/views/<<Controller_name>>/new.html.erb
   identical    app/views/<<Controller_name>>/edit.html.erb
      invoke  helper
   identical    app/helpers/<<Controller_name>>_helper.rb
      invoke  assets
      invoke    coffee
   identical      app/assets/javascripts/<<Controller_name>>.coffee
      invoke    scss
   identical      app/assets/stylesheets/<<Controller_name>>.scss
Running via Spring preloader in process 62

Below are my compose file and sections of a docker inspect I felt would be relevant to this problem. FYI my compose file is in the docker dir within the project dir.

DOCKER-COMPOSE.yml

version: '2'
services:
  my-proj:
    command: ["/opt/docker/wait-for-it.sh", "db:5432", "--", "/opt/bin/setup"]
    image: rails:latest
    volumes:
      - ../:/opt
    expose:
      - 4000
    ports:
      - 4000:4000
    depends_on:
      - db
    stdin_open: true
    tty: true
  db:
    image: postgres:9.6.1
    expose:
      - 5432
    ports:
      - 5432:5432
    environment:
      - POSTGRES_PASSWORD=psswd
      - POSTGRES_USER=user
      - POSTGRES_DB=my_proj_dev

DOCKER INSPECT

"HostConfig": {
            "Binds": [
                "/c/Users/ME/Docker/my-proj:/opt:rw"
            ],
...
"Mounts": [
            {
                "Type": "bind",
                "Source": "/c/Users/ME/Docker/my-proj",
                "Destination": "/opt",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
...
"Config": {
            ...
            "Image": "rails:latest",
            "Volumes": {
                "/opt": {}
            },
            "WorkingDir": "/usr/src/app",

In my noob wisdom I have a feeling it may have something to do with the "Propagation": "rprivate" property? I have googled how to convert this to rshared but found nothing on doing this in a docker-compose file.

As always any help or direction will be greatly appreciated.

While writing this question I came across this one from another post that is slightly similar to my issue.

slappy-x
  • 318
  • 5
  • 13

0 Answers0