LoginSignup
6
5

More than 5 years have passed since last update.

GCE 上の docker コンテナ内部から gsutil を使う

Posted at

概要

GoogleComputeEngine (GCE) インスタンスから gsutil などのツールを使うと,metadata サーバから適切に情報を取得してサービスアカウントを用いた認証を自動で行ってくれる.しかし,インスタンス内で走っている docker コンテナから同じことをする場合,boto の設定が必要となる.

設定方法

/etc/boto.cfg

[GoogleCompute]
service_account = default

を追加する.下記は,Dockerfile に記述する場合の例.

FROM ubuntu

RUN apt-get update && \
    apt-get install -y libssl-dev python-pip python-dev \
                       libffi-dev python-crypto python-openssl
RUN pip install -U gsutil
RUN echo "[GoogleCompute]\nservice_account = default" >> /etc/boto.cfg

参考

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5