Home > Enterprise >  Docker-compose image building error -> [Errno 2] No such file or directory on building
Docker-compose image building error -> [Errno 2] No such file or directory on building

Time:09-24

I have a microservice and I am trying to run it via docker-compose. You can see my directory structure below.

When I build that image inside GUI directory using docker build, It runs smoothly. But when I use docker-compose it gives this error:

[Errno 2] No such file or directory on building.

What is the problem here?

Directory Structure

my_project
|__docker-compose.yml
|__GUI
|____dockerfile
|____gui.py\

docker-compose.yml

version: "3"
services:
  service_gui:
    build: 
      context: .
      dockerfile: ./GUI/dockerfile
    ports:
      - 8080:8080

dockerfile

FROM continuumio/miniconda3
WORKDIR /app
COPY . .

RUN pip install dash
EXPOSE 8080
ENTRYPOINT [ "python","gui.py"]

CodePudding user response:

If you normally run

cd GUI
docker build -t service_gui .

it would be equivalent to run

# in the parent directory
docker build -t service_gui ./GUI

in both cases passing the GUI directory as the Docker build context. That means, in the docker-compose.yml file, you can specify

build:
  context: GUI            # `docker build` directory parameter
  dockerfile: Dockerfile  # `docker build -f` option

or, equivalently,

build: GUI  # directory name only, default Dockerfile name
  • Related