2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【OCI】DockerでOCI-CLIを実行する。

Last updated at Posted at 2019-10-20

はじめに

OCIを操作するOracle Cloud Command Line Interface(OCI CLI)の実行環境を用意する。
なるべく環境を汚したくない&バージョンアップ楽にしたいタイプなのでDockerで用意します。

今回作成したDocker環境はGit hubで公開しています。
manaki-naoe/docker-oci-cli

準備

Dockerfileの作成

Dockerfile
FROM python:3.8.0-alpine3.10
LABEL maintainer "Manaki <manakinaoe@gmail.com>"

RUN set -xe && \
    apk add --no-cache --update \
        alpine-sdk \
        libffi \
        libffi-dev \
        openssl \
        openssl-dev && \
    pip install --upgrade pip && \
    pip install --no-cache-dir \
        oci \
        oci-cli

ENTRYPOINT ["/usr/local/bin/oci"]

ConfigファイルとAPI Keyの設置ディレクトリを作成

$ mkdir .oci

構造

.
├── .oci
└── Dockerfile

イメージの作成

$ docker build -t oci-cli .

OCI CLIの実行

実行方法

※.ociがあるディレクトリで実行します

$ docker run --rm -v ${PWD}/.oci:/root/.oci -it oci-cli:latest 《OCI CLI Command》

OCI CLI Command Reference


実行例

ConfigファイルとAPI Keyの作成

$ docker run --rm -v ${PWD}/.oci:/root/.oci -it oci-cli:latest setup config

その他

aliasでコマンドを楽にする

以下を~/.bashrcに追記します。
《Repository path》をご自身の環境に合わせて.ociがあるディレクトリに置き換えてください。

~/.bashrc
alias oci-cli='docker run --rm -v《Repository path》/.oci:/root/.oci -it oci-cli:latest "$@"'

反映させる

$ source ~/.bashrc

実行

$ oci-cli --version
2.6.9
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?