Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WORKDIR cannot create a nonexistent directory #5373

Closed
Aeron opened this issue Mar 1, 2024 · 5 comments
Closed

WORKDIR cannot create a nonexistent directory #5373

Aeron opened this issue Mar 1, 2024 · 5 comments

Comments

@Aeron
Copy link

Aeron commented Mar 1, 2024

Description

Most of the issue details and a description are here. I thought I faced a Github runner problem, but it was reproducible with different OSes and versions.

The brief version is that I have a perfectly fine Dockerfile that can be built into an image by Docker. But any attempt to do it via Buildah ends up with a mkdir: not a directory error from the WORKDIR directive with a nonexistent path.

Yet something like the following example will build, no problem:

FROM alpine:latest
WORKDIR /usr/src/nonexistent

So, I suspect the ADD directive that precedes the WORKDIR plays a role here. It has a Git source, and it creates a directory that is a part of a nonexistent directory’s path. Maybe it’s just an optimal combo.

I tested it on Ubuntu 22.04 and apt-installed Buildah 1.23.1 (both VM and GitHub runner), Ubuntu 23.10 and apt-installed Buildah 1.28.2, Debian 12 and compiled Buildah 1.35.0-dev. And everything as stock as possible. The result was the same.

Steps to reproduce the issue

  1. Install or build the buildah
  2. Get the original Dockerfile
  3. Build it, like so:
    buildah bud -f ./Dockerfile --format docker -t test .
  4. Get the error:
    error building at STEP "WORKDIR /usr/src/mimalloc/build": copier: mkdir: error checking directory "/usr/src/mimalloc/build": mkdir /usr/src/mimalloc/build: not a directory
    

Expected results

A build finishes without mkdir (or any) errors.

Actual results

A build ends up with code 125 and mkdir: not a directory error.

Outputs

The outputs below are for the Ubuntu 22.04 VM and Buildah 1.23.1 pair only because all of them are (kind of) irrelevant between OSes and versions. It looks like it’s possible to recreate anywhere.

Output of apt list buildah

buildah/jammy,now 1.23.1+ds1-2 arm64 [installed]

Output of buildah version

Version:         1.23.1
Go Version:      go1.17
Image Spec:      1.0.1
Runtime Spec:    1.0.2-dev
CNI Spec:        0.4.0
libcni Version:  
image Version:   5.16.0
Git Commit:      
Built:           Thu Jan  1 01:00:00 1970
OS/Arch:         linux/arm64
BuildPlatform:   linux/arm64/v8

Output of cat /etc/*release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
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"
UBUNTU_CODENAME=jammy

Output of uname -a

Linux ubuntu-22.04 6.5.13-orbstack-00122-g57b8027e2387 #1 SMP Tue Feb  6 07:48:26 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

Output of cat /etc/containers/storage.conf

cat: /etc/containers/storage.conf: No such file or directory
@rhatdan
Copy link
Member

rhatdan commented Mar 3, 2024

I tried to build using your Dockerfile, and saw the same break. Then I removed all code from the WORKDIR that was blowing up down. I thin ran a container on the produced image and I am seeing the parent directory of the WORKDIR is a file not a directory.

$ podman run -ti test stat /usr/src/mimalloc
  File: /usr/src/mimalloc
  Size: 484168    	Blocks: 952        IO Block: 4096   regular file
Device: 71h/113d	Inode: 852856278   Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1970-01-01 00:00:00.000000000 +0000
Modify: 1970-01-01 00:00:00.000000000 +0000
Change: 2024-03-03 10:08:32.179225767 +0000
Error: building at STEP "WORKDIR /usr/src/mimalloc/build": copier: mkdir: error checking directory "/usr/src/mimalloc/build": mkdir /usr/src/mimalloc/build: not a directory

is complaining because it can not create /usr/src/mimalloc/build because /usr/src/mimalloc is not a directory?

@rhatdan
Copy link
Member

rhatdan commented Mar 3, 2024

Looks like buildah treated file path as a web side rather then a git side and just downloaded the web page.

<!DOCTYPE html>
<html
  lang="en"
  
  data-color-mode="auto" data-light-theme="light" data-dark-theme="dark"
  data-a11y-animated-images="system" data-a11y-link-underlines="true"
  >




  <head>
    <meta charset="utf-8">
  <link rel="dns-prefetch" href="https://github.githubassets.com">
  <link rel="dns-prefetch" href="https://avatars.githubusercontent.com">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
  <link rel="preconnect" href="https://github.githubassets.com" crossorigin>
  <link rel="preconnect" href="https://avatars.githubusercontent.com">

  

  <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-0eace2597ca3.css" /><lin--More-- (0% of 484153 bytes)

@rhatdan
Copy link
Member

rhatdan commented Mar 3, 2024

@flouthoc @nalind Does ADD not support Git repos in Buildah yet?

@flouthoc
Copy link
Collaborator

flouthoc commented Mar 3, 2024

@rhatdan Buildah does support ADD with source as a git repo. Not yet there is an open issue about it #4974

@Aeron
Copy link
Author

Aeron commented Mar 3, 2024

Oh, I see. It was ADD after all. So, this issue is a duplicate, kind of. I’ll close it then.

@Aeron Aeron closed this as completed Mar 3, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants