Phusion Passenger and Docker-Compose Issue with Permissions

I am encountering a permissions issue when running docker-compose and Phusion Passenger’s docker image.

Specifically, the error is:
Permission denied @ rb_sysopen - /var/www/my_app/tmp/.....

  • Building the MongoDB Docker image
  • Why does DockerFile ADD not dereference symbolic links?
  • Control docker-compose from Gradle build script
  • how to configure docker to use apache and php in separate containers
  • Sharing exclusive files to docker instances from host
  • Not able to connect to AS in Docker container
  • My docker-compose.yml file contains the following information:

      build: .
      container_name: happy_passenger
        - "80:80"
        - .:/var/www/my_app
       - redis
      container_name: my_redis
      image: redis
        - "6379:6379"

    When running docker-compose up, the application loads, but then I am met with the Permission denied @ rb_sysopen error.

    My Dockerfile is relatively straight-forward too:

    # Dockerfile
    FROM phusion/passenger-ruby21:0.9.17
    MAINTAINER meoww- ""
    # Set correct environment variables.
    ENV HOME /root
    # Initialize "in production"
    ENV RAILS_ENV production
    # Use baseimage-docker's init process.
    CMD ["/sbin/my_init"]
    # Turn on Nginx
    RUN rm -f /etc/service/nginx/down
    # Remove the default site that comes with Nginx
    RUN rm /etc/nginx/sites-enabled/default
    ADD nginx.conf /etc/nginx/sites-enabled/my_app.conf
    WORKDIR /tmp
    ADD Gemfile /tmp/
    ADD Gemfile.lock /tmp/
    RUN bundle install
    ADD . /var/www/my_app
    RUN chown -R app:app /var/www/my_app
    # Clean up APT when done.
    RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


    1. When I modify my docker-compose.yml file and remove the volumes: block, I am able to view my application. Unfortunately, if I don’t have a volumes: block, then I am required to rebuild the docker image after every code change that I make. So that option will not work.

    2. I noticed that when the application starts, I’m seeing a permissions error too:

    App 66 stderr: Rails Error: Unable to access log file. Please ensure that /var/www/my_app/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /var/www/my_app/log/development.log)

    Per the error above (#2), I tried adding a RUN chmod -R 0664 /var/www/my_app to my Dockerfile and removing + rebuilding everything (e.g. docker rmi [image], then docker-compose up which rebuilt my image). This didn’t seem to have any impact on this issue.

    At this point, I’m inclined to think that there’s something wrong with the way I’m setting up the docker-compose read-write permissions, but I am not finding any clear documentation on what I need to change.

    Any advice would be appreciated.

    Thanks in advance.

  • Dockerized Jira behind traefik-Proxy throws Mixed-Content-Error
  • Docker Connect to Remote Instance of WordPress
  • Is there a way to use drone with self-signed certificates?
  • Why is mounting the /var/hyperledger/production to the host volume causing an error?
  • How to pass -mem to dockerized Play application
  • access docker container in kubernetes
  • One Solution collect form web for “Phusion Passenger and Docker-Compose Issue with Permissions”

    It appears that the issue is a bug with boot2docker and how it mounts volumes on OSX. First, I ran the command docker inspect happy_passenger. This gave me the following information about my volume:

    "Mounts": [
            "Source": "/Users/meow/test/www/demodocker",
            "Destination": "/var/www/my_app",
            "Mode": "rw",
            "RW": true

    The volume was showing up in docker as Read/Write (R/W) enabled. Under normal circumstances, this would indicate that I should be able to use a mounted volume and write to the file system. However, since a bug exists with the R/W permissions, I was encountering various errors due to the fact that the permissions were wrong. Even running chmod -R 777 . on the shared and host directories did not fix the issue

    To fix this, I did the following:

    In my dockerfile

    # Dockerfile
    FROM phusion/passenger-ruby21:0.9.17
    MAINTAINER meoww- ""
    # Hack to get around the boot2docker issue.
    RUN usermod -u 1000 app
    RUN usermod -G staff app

    After adding the two commands RUN usermod -u 1000 app and RUN usermod -G staff app I was able to successfully load up my containerized application when using docker-compose up.

    Hope this helps someone fix their docker permission errors/docker mounted volume bug.

    Also, here’s a link to the issue in Github:

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.