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

【備忘録】DockerfileでCOPYするときの書き方

Last updated at Posted at 2021-09-04

DockerfileのCOPY時のディレクトリ指定をどのように書けば良いかわからなかったので、実験してみた。

ローカルのディレクトリ構成

$ tree
.
├── Dockerfile
├── dir1
│   ├── sample1.txt
│   └── sample2.txt
└── dir2
    └── sample3.txt

パターンA

Dockerfile
FROM node:14.17.6

WORKDIR /app

RUN apt update && apt install tree

COPY . .

結果は以下の通り↓

# tree -A
.
├── Dockerfile
├── dir1
│   ├── sample1.txt
│   └── sample2.txt
└── dir2
    └── sample3.txt

パターンB

Dockerfile
FROM node:14.17.6

WORKDIR /app

RUN apt update && apt install tree

COPY ./ .

結果は以下の通り↓

# tree -A
.
├── Dockerfile
├── dir1
│   ├── sample1.txt
│   └── sample2.txt
└── dir2
    └── sample3.txt

パターンAと同じになった

パターンC

Dockerfile
FROM node:14.17.6

WORKDIR /app

RUN apt update && apt install tree

COPY ./* .

結果は以下の通り↓

# tree -A
.
├── Dockerfile
├── sample1.txt
├── sample2.txt
└── sample3.txt

ローカルのディレクトリ構成を無視して、全てのファイルが同じ階層にコピーされた

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