title: How to authenticate Docker container with Google Service
body: <p>The Docker container runs a Python server and publishes messages to <code>Google Pubsub</code> message service. </p>
  
  <p>In order for this container to be able to use <code>Google Pubsub</code> service I set <code>GOOGLE_APPLICATION_CREDENTIALS</code> environment variable pointing it to <code>service_key.json</code> file that I downloaded after creating a <code>Service Account Key</code> by opening <code>Google Cloud Console</code> and then navigation to:</p>
  
  <p><code>API's &amp; Services</code> > <code>Credentials</code> > <code>Create Credentials</code> > <code>Service Account Key</code>. </p>
  
  <p><a href="https://i.stack.imgur.com/p1Xtc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p1Xtc.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/xU4Gg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xU4Gg.png" alt="enter image description here"></a></p>
  
  <p>The <code>service_key.json</code> file needs to be copied to a container's local disk otherwise it won't be able to read it. </p>
  
  <p>While this approach works and the Docker container is now authorized to use Google Pubsub service with the <code>service_key.json</code> file credentials I believe it is not a very secure solution since the <code>service_key.json</code> file is now hosted on a cloud with the container itself. </p>
  
  <p>Is there a way to authorize the Docker container with the Google Service credentials without copying <code>service_key.json</code> file to its local disk? </p>