Phusion/passenger-full customization

Phusion provides really awesome docker for the community. I used its baseimage as well as the passenger-full, which I later ran into some problems. I reckon that it'd be good to share some lessons that I learnt.

Environment

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

$>docker version
Client version: 1.0.1
Client API version: 1.12
Go version (client): go1.2.1
Git commit (client): 990021a
Server version: 1.0.1
Server API version: 1.12
Go version (server): go1.2.1
Git commit (server): 990021a

phusion/passenger-full   0.9.14              9a51fba1d144

Lessons

Why doesn't my ssh public key setting work?

It can be various issues

  1. user 'app' isn't enabled by default

    It's just a document issue. The user need to be unlocked before you can login using a private key file. Otherwise sshd won't let you in. RUN usermod -U app

  2. docker's issue 6047 This issue was very tricky and took me lots of time before finding out it was a docker's issue. The .ssh directory wasn't let app access even though it shows accessible mode. Deleting and re-add it will address the issue.

The overall part is

RUN usermod -U app
ADD authorized_keys /tmp/authorized_keys
RUN rm -rf /home/app/.ssh 
RUN install -m 700 -g app -o app -d /home/app/.ssh
RUN install -m 600 -g app -o app /tmp/authorized_keys /home/app/.ssh/authorized_keys
RUN install -m 600 -g root -o root /tmp/authorized_keys /root/.ssh/authorized_keys