docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
751 stars 84 forks source link

Building from git and using fragment section result in error #1102

Open Ryther opened 4 years ago

Ryther commented 4 years ago

Expected behavior

Building an image from a git repository and specifying the context to use should build normally, as described here: Build#git-repositories

Actual behavior

The building stop almost immediatly and report this error:

unable to prepare context: unable to 'git clone' to temporary context directory: stat /tmp/docker-build-gitXXXXXXXXX/lam-packaging/docker: no such file or directory

During the build process, under /var/lib/docker/tmp docker creates a new build directory named docker-builderYYYYYYYYY where it clones the repository.

Steps to reproduce the behavior

  1. Launch the command: sudo docker build https://github.com/LDAPAccountManager/lam.git#master:lam-packaging/docker

It can be also reproduced with docker-compose:

version: "3.8"
services:
  ldapaccountmanager:
    image: ldapaccountmanager/lam
    container_name: ldapaccountmanager
    build: 
      context: https://github.com/LDAPAccountManager/lam.git#master:lam-packaging/docker
      args:
        LAM_RELEASE: 7.2
    ports:
      - 8099:80
    volumes:
      - ${HOME}/.services/ldapaccountmanager/etc/ldap-account-manager:/etc/ldap-account-manager
      - ${HOME}/.services/ldapaccountmanager/var/lib/ldap-account-manager/config:/var/lib/ldap-account-manager/config
      - ${HOME}/.services/ldapaccountmanager/var/lib/ldap-account-manager/sess:/var/lib/ldap-account-manager/sess
    environment:
      - LAM_PASSWORD=REDACTED
      - LAM_LANG=en_US
      - LDAP_SERVER=REDACTED
      - LDAP_DOMAIN=REDACTED
      - LDAP_BASE_DN=REDACTED
      - ADMIN_USER=REDACTED
      - DEBUG=true
    restart: unless-stopped

I cannot try to reproduce the error on a x86 PC. I've tried to reproduce it using Windows 10 but the feature seems to not be supported (tried both cmd and wsl):

[+] Building 0.0s (1/1) FINISHED
 => ERROR [internal] load git source https://github.com/LDAPAccountManager/lam.git#master:lam-packaging/docker                                                                                                                                                                                                                                                                                                                         0.0s ------
 > [internal] load git source https://github.com/LDAPAccountManager/lam.git#master:lam-packaging/docker:
------
failed to solve with frontend dockerfile.v0: failed to resolve dockerfile: failed to build LLB: failed to load cache key: subdir not supported yet

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a6621
 Built:             Mon Jun 22 15:46:28 2020
 OS/Arch:           linux/arm64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a6621
  Built:            Mon Jun 22 15:44:59 2020
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 31
  Running: 31
  Paused: 0
  Stopped: 0
 Images: 71
 Server Version: 19.03.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: journald
 Cgroup Driver: cgroupfs
 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: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.9.230-96
 Operating System: Ubuntu 20.04.1 LTS
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 3.625GiB
 Name: odroid
 ID: CAS6:RN5L:4HB2:NZMO:TEW7:SKOW:IN2N:KEVE:XKFD:3NVP:YP3G:TA4Y
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

Additional environment details (AWS, VirtualBox, physical, etc.)

Physical device: Odroid N2 (arm64/v8)

Output of cat /etc/os-release

NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Output of uname -a

Linux odroid 4.9.230-96 #1 SMP PREEMPT Fri Aug 21 13:55:00 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

Output of cat /proc/version

Linux version 4.9.230-96 (root@builder_n2) (gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-6ubuntu2) ) #1 SMP PREEMPT Fri Aug 21 13:55:00 UTC 2020

Output of git version

git version 2.25.1

thaJeztah commented 3 years ago

thanks for reporting; specifying subdirectories when building from a remote git source is currently not supported when using buildkit; https://github.com/moby/buildkit/issues/1684