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/.....

  • Does it make sense to install the runtime on docker?
  • Set profile on bootstrap.yml in spring cloud to target different config server
  • Within Docker VM, Gulp-Watch Seems to not work well on volumes hosted from the host OS
  • how to debug python in IntelliJ idea using vagrant docker
  • How to run pip3+git from behind proxy with docker?
  • Why won't my docker-cmd execute with sh?
  • 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.

  • Using docker gcplogs (Google Cloud Logging driver) on digital ocean with docker compose
  • Allow a container running via docker-machine to connect with Mysql or XDEBUG port on parent OSX system without using an OSX DHCP assigned ip address?
  • How to communicate with Kafka server running inside a docker
  • Where my files exist in Docker image?
  • How to get `docker run` full arguments?
  • Sharing a single file from host machine with Docker Container and having the Container r+w to same file
  • 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.