> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/kontenaimjisukyan/local-image-scanning/circleci-setup-for-local-image-scanning.md).

# ローカルイメージスキャン向け CircleCI 設定

Aikido Security Local Scanner は、Aikido Security のスキャンを自社環境内で実行できるようにするツールです。これにより、データが社外に出ることはありません。スキャンはローカルで実行され、その結果は Aikido Security プラットフォームにアップロードされます。この構成により、レジストリに送信される前に、自分のマシン上または CI/CD パイプライン内で任意のイメージをローカルにスキャンできます。

## 画像のローカルスキャンのセットアップ方法 <a href="#how-to-set-up-local-scanning-for-images" id="how-to-set-up-local-scanning-for-images"></a>

### 1. 認証トークンを取得する <a href="#id-1-get-your-authentication-token" id="id-1-get-your-authentication-token"></a>

1. 次へ移動します： [ローカルスキャナーのイメージ設定ページ](https://app.aikido.dev/settings/container-image-registry/add/localscan)
2. 認証トークンを生成してコピーします。このトークンを表示できるのは一度だけであることに注意してください。
3. このトークンを引数として追加する `--apikey` プロジェクトで Local Scanner を実行する際に。
4. 次へ移動して、このトークンを環境変数として保存します。 **プロジェクト設定** > **環境変数** > **環境変数を追加** CircleCI で。

   ![APIキーの環境変数が、値と作成タイムスタンプのオプション付きで追加されました。](/files/17b76148573cdab8db336dbc232b99a20552ea6b)

### 2. Local Scanner の実行 <a href="#id-2-running-the-local-scanner" id="id-2-running-the-local-scanner"></a>

​\
これで、あとはイメージに対してスキャナーを実行するだけです。

```yaml
version: 2.1

jobs:
  run-aikio-scan:
    machine:
      image: ubuntu-2204:current

    steps:
      - run:
          name: "ここにビルドステップを入力"
          command: docker build .
      - run:
          name: "Aikido スキャンを実行"
          command: docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aikidosecurity/local-scanner image-scan your-local-image-name --apikey "$AIKIDO_API_KEY"
  my-workflow:
    jobs:
      - run-aikio-scan:
          filters:
            branches:
              only:
                - master
```

CI でこれを実行する場合は、production と feature の結果が Aikido 内で混ざらないように、feature ブランチを元にしたイメージに対してスキャンを実行しないよう注意してください。

レジストリにプッシュする前にリリースゲート付きのスキャンを実行するには、次のような Pipeline を実行できます:

```yaml
version: 2.1

jobs:
  run-aikio-scan:
    machine:
      image: ubuntu-2204:current

    steps:
      - run:
          name: "ここにビルドステップを入力"
          command: docker build .
      - run:
          name: "Aikido スキャンを実行"
          command: docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aikidosecurity/local-scanner image-scan your-local-image-name --apikey "$AIKIDO_API_KEY" --fail-on critical
      - run:
          name: "ここにプッシュステップを入力"
          command: docker image push ...
  my-workflow:
    jobs:
      - run-aikio-scan:
          filters:
            branches:
              only:
                - master
```

で指定する重大度を `--fail-on` ニーズに合わせて調整してください。

### 4. スキャン結果を確認する <a href="#id-4-check-your-scanning-results" id="id-4-check-your-scanning-results"></a>

最初のスキャンが完了したら、Aikido Feed に移動して結果を確認できます。指定した名前のイメージが Aikido UI に作成され、スキャンの結果がすべて含まれています。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/kontenaimjisukyan/local-image-scanning/circleci-setup-for-local-image-scanning.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
