Help us understand the problem. What is going on with this article?

Docker(docker-compose)でCOPYできない

More than 1 year has passed since last update.

DockerFile での COPY の書き方

docker-compose でイメージをビルドしたときに自分がハマったところを記載しておきます。
ちなみに「ADD」でも同様?らしいです。

※docker-compose を使わない場合だったり、
以下と異なるバージョンならこれらの問題も発生しないのかもしれません

  • 試したバージョン
$ docker -v
Docker version 1.12.6, build 88a4867/1.12.6
$ docker-compose -v
docker-compose version 1.12.0, build b31ff33

絶対パスだとコピーできない

COPY /home/userA/test/hoge.txt /home/test/

→ failed to build

相対パスはどこから開始?

Dockerfile が置いてあるパス

相対パスなのにコピーできない

COPY ../test/hoge.txt /home/test/

→ failed to build
※ 「../」がダメっぽい?

【Dockerfile以下の】相対パスならコピー成功!

~
(Dockerfile が置いてあるパス以下の相対パス)
COPY test/hoge.txt /home/test/

→ OK

試行錯誤していたので、もし間違い(カンチガイ)があったらご指摘いただけると助かります。

t_n
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした