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.

default unable to prepare context: path "/path/to/Dockerfile" not found というエラーへの対処

Last updated at Posted at 2024-01-18

はじめに

docker composeで環境構築を試みたところ,以下のようなエラーが発生した.

error
docker: default unable to prepare context: path "/path/to/Dockerfile" not found

ディレクトリ構成などは以下の通り.

tree
.
├── data
├── docker-compose.yml
└── src
    └── Dockerfile.src
docker-compose.yml
version: '3'

services:
  src:
    build: ./src/Dockerfile.src
    container_name: src
    tty: true
    volumes:
      - ./src:/home/workdir

  mongo:
    image: mongo:7.0.5-rc0-jammy
    ~~ 省略 ~~

networks:
  dbnet:
    name: my_dbnet
Dockerfile.src
FROM ubuntu:22.04

WORKDIR /home/workdir

RUN something_to_do

まずは検索

検索したところ,以下の記事を発見.

これに従って,docker-compose.ymlを編集.

docker-compose.yml
version: '3'

services:
  src:
    build: 
      context: ./src
      dockerfile: ./Dockerfile.src
    container_name: src
    tty: true
    volumes:
      - ./src:/home/workdir

  mongo:
    image: mongo:7.0.5-rc0-jammy
    ~~ 省略 ~~

networks:
  dbnet:
    name: my_dbnet

これでエラーが解消.

最後に

何故,上記の操作でエラーが解消できたのかは不明です.
調べてみたのですが,元のようにbuildをしている記事もあり,何が根本的な原因であるかが掴めませんでした.(予想:明示的に指定するか,そうでないかの違い?)

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?