LoginSignup
0
0

DockerfileのCOPYで上の階層を参照したい

Last updated at Posted at 2023-07-25

環境

work/
 ├ text.txt
 ├ docker/
 │ └ docker-compose.yml
 │ └ Dockerfile
 └ lib/

問題

以下でエラー発生

Dockerfile
FROM ubuntu:latest

COPY ../text.txt /home/text.txt

解決

  1. コンテキストをかえる。以下は例
    docker-compose.yml
    version: '3'
    services:
     service:
      build:
        context: ../
        dockerfile: docker/Dockerfile
      tty: true
    
  2. Dockerfileを書き換える
    Dockerfile
    FROM ubuntu:latest
    
    COPY text.txt /home/text.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