title: Sharing /etc/passwd between two Docker containers
body: <p>I'm trying to containerize application which consists of two services defined. One is basic server running on specific port and second one is SSH server. The first service creates users by executing standard unix commands (managing user and their ssh keys) and they can login to second ssh service. Each service is running in separate container and I use Docker Compose to make it all running together. </p>
  
  <p>The issue is that I'm unable to define Docker volumes so that I can user created by first service can use second service. I need share files like /etc/passwd, /etc/shadow, /etc/group between both services.</p>
  
  <p>What I tried:</p>
  
  <p>1) Define volumes for each file</p>
  
  <ul>
  <li>Not supported in Docker Compose (it can use only directories as volumes)</li>
  </ul>
  
  <p>2) Replace /etc/passwd with symlink to copy in volume</p>
  
  <ul>
  <li>as described <a href="https://stackoverflow.com/questions/33013444/can-not-add-new-user-in-docker-container-with-mounted-etc-passwd-and-etc-shado">here</a></li>
  </ul>
  
  <p>3) Set whole /etc as volume</p>
  
  <ul>
  <li>doesn't work (only some files get from image to volume)</li>
  <li>is ugly</li>
  </ul>
  
  <p>I would be thrilled with any suggestion or workaround which wouldn't require put both services in one container.</p>