1
0

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 1 year has passed since last update.

はじめに

この記事では、.dockerignore の概要及び基本的な利用方法について記載します。

.dockerignore の概要

.dockerignore を利用すると、.dockerignore 内に追加されたファイルやディレクトリをビルダー(ex. Docker デーモン)に送信しなくなります。これにより、ビルド効率が改善されます。また、機密情報の保持にも役立ちます。

.dockerignore の利用方法

次は .dockerignore の基本的な利用方法について記載します。

ファイル位置

.dockerignore を置く位置は、ビルド時、引数として指定されたディレクトリになります。
例えば、以下の compose.yaml 及びディレクトリ構成の場合、.dockerignore は、/dcoker/app に置きます。

compose.yaml
services:
  app:
    ports:
      - "${APP_HOST_MACHINE_PORT:-8000}:8000"
    volumes:
      - type: bind
        source: ./src
        target: /my-work
    build: ./docker/app
├─compose.yaml
├─docker
  ├─app
    ├─.dockerignore # 追加
    └─Dockerfile
  └─db
└─src

ファイルの記載方法

.dockerignore に以下の値を記載すると、.git.env は、ビルダーに送信されなくなります。

.dockerignore
**/.git
**/.env

参考

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?