docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.15k stars 5.25k forks source link

[BUG] Custom dockerfile paths does not work on macOS #10466

Closed bitterteriyaki closed 1 year ago

bitterteriyaki commented 1 year ago

Description

# docker-compose.yml
version: '3.9'

services:
  bot:
    <<: &bot
      # Image name is changed in production:
      image: 'keth:dev'
      build:
        target: development_build
        context: .
        dockerfile: ./docker/bot/Dockerfile
        args:
          BOT_ENV: development
        cache_from:
          - "keth:dev"
          - "keth:latest"
          - "*"
      networks:
        - botnet
      env_file:
        - ./config/.env

    command: python -Wd launcher.py

networks:
  # Network for internals:
  botnet:

Project tree:

.
├── docker
│      └── bot
│         └── Dockerfile
├── docker-compose.override.yml
├── docker-compose.yml
# etc, not relevant.

Steps To Reproduce

Running docker compose up:

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile:
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 32B done
#1 DONE 0.1s
#1 transferring dockerfile: 2B done

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#1 DONE 0.2s

#2 [internal] load .dockerignore
#2 transferring context:
#2 DONE 0.2s

[+] Running 1/1
 ! bot Warning 3.5s 
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2662316997/Dockerfile: no such file or directory

Compose Version

Docker Compose version v2.17.2
### Docker Environment

Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.10.4)
  compose: Docker Compose (Docker Inc., v2.17.2)
  dev: Docker Dev Environments (Docker Inc., v0.1.0)
  extension: Manages Docker extensions (Docker Inc., v0.2.19)
  init: Creates Docker-related starter files for your project (Docker Inc., v0.1.0-beta.2)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.25.0)
  scout: Command line tool for Docker Scout (Docker Inc., v0.9.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.24
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2456e983eb9e37e47538f59ea18f2043c9a73640
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.675GiB
 Name: docker-desktop
 ID: LNDL:P4TF:U7QE:POHU:XIJN:GPRY:ZIO3:4AXN:RG7L:KXHC:6LWL:RNMA
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

ndeloof commented 1 year ago

I can't see anything wrong with this configuration. According to build logs

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 32B done

Dockerfile is well identified on configured path and send to builder.

Please run docker compose config to check the parsed/normalized compose model being used by Docker Compose.

bitterteriyaki commented 1 year ago

I can't see anything wrong with this configuration. According to build logs

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 32B done

Dockerfile is well identified on configured path and send to builder.

Please run docker compose config to check the parsed/normalized compose model being used by Docker Compose.

Hi, @ndeloof. Thanks for your answer! Here is the output of the docker compose config command:

name: keth
services:
  bot:
    build:
      context: /Users/kyomi/Repositories/keth
      dockerfile: ./docker/bot/Dockerfile
      args:
        BOT_ENV: development
      cache_from:
      - keth:dev
      - keth:latest
      - '*'
      target: development_build
    command:
    - python
    - -Wd
    - launcher.py
    environment:
      DISCORD_TOKEN: <my-bots-token-here>
    image: keth:dev
    networks:
      botnet: null
  web:
    build:
      context: /Users/kyomi/Repositories/keth
      dockerfile: Dockerfile
      args:
        GID: "1000"
        UID: "1000"
    networks:
      default: null
    volumes:
    - type: bind
      source: /Users/kyomi/Repositories/keth
      target: /code
      bind:
        create_host_path: true
networks:
  botnet:
    name: keth_botnet
  default:
    name: keth_default
bitterteriyaki commented 1 year ago

Oh, my docker-compose.override.yml was using a wrong service name. 🤦 Changed it and now it's working perfectly, sorry for wasting your time and thank you for the support. Closing this issue.