podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

"build" field behaviour inconsistent with docker-compose

Open evanshortiss opened this issue 3 years ago • 9 comments

The compose YAML below results in an OSError: Dockerfile not found in ./Dockerfile.node. The same YAML works with docker-compose but I noticed it has this error when I started testing with podman-compose.

It can be fixed by renaming my Dockerfile.node to Dockerfile and changing the build value to a period, i.e change build: Dockerfile.node to build: ..

This indicates the build param expects a path to a directory containing a file named Dockerfile, but cannot be passed the path to a specific Dockerfile, right?

version: '3'

services:
  client:
    container_name: client
    image: quay.io/evanshortiss/client:latest
    depends_on:
      - server
    ports:
      - 8080:8080/tcp
    restart: unless-stopped

  server:
    container_name: server
    # This line causes an error!
    build: ./Dockerfile.node
    command: sh -c "echo 'Server starting npm install. Please wait....' && npm i && npm run dev"
    volumes:
      - '../../server:/usr/src/app/'
    ports:
      - 8181:8181/tcp
    environment:
      HTTP_PORT: 8181
      LOG_LEVEL: debug
    restart: unless-stopped

evanshortiss avatar May 18 '21 18:05 evanshortiss

I can confirm that. Trying to build that one gives me an error: https://hub.docker.com/r/awesometechnologies/synapse-admin https://github.com/Awesome-Technologies/synapse-admin

version: "3"

services:
  synapse-admin:
    container_name: synapse-admin
    hostname: synapse-admin
    build:
      context: https://github.com/Awesome-Technologies/synapse-admin.git
      # args:
      #   - NODE_OPTIONS="--max_old_space_size=1024"
    ports:
      - "8080:80"
    restart: unless-stopped

The error:

$ podman-compose build
['podman', '--version', '']
using podman version: podman version 3.2.2
Traceback (most recent call last):
  File "/sbin/podman-compose", line 33, in <module>
    sys.exit(load_entry_point('podman-compose==0.1.7.dev0', 'console_scripts', 'podman-compose')())
  File "/usr/lib/python3.9/site-packages/podman_compose.py", line 1547, in main
    podman_compose.run()
  File "/usr/lib/python3.9/site-packages/podman_compose.py", line 893, in run
    cmd(self, args)
  File "/usr/lib/python3.9/site-packages/podman_compose.py", line 1111, in wrapped
    return func(*args, **kw)
  File "/usr/lib/python3.9/site-packages/podman_compose.py", line 1198, in compose_build
    build_one(compose, args, cnt)
  File "/usr/lib/python3.9/site-packages/podman_compose.py", line 1171, in build_one
    raise OSError("Dockerfile not found in "+ctx)
OSError: Dockerfile not found in https://github.com/Awesome-Technologies/synapse-admin.git

HidingCherry avatar Jul 11 '21 07:07 HidingCherry

Context is expected to be a directory

muayyad-alsadi avatar Jul 11 '21 08:07 muayyad-alsadi

Please take look https://docs.docker.com/compose/compose-file/compose-file-v3/#context

context

Either a path to a directory containing a Dockerfile, or a url to a git repository.

MartinX3 avatar Jul 11 '21 08:07 MartinX3

https://docs.docker.com/compose/compose-file/compose-file-v3/#context

context

Either a path to a directory containing a Dockerfile, or a url to a git repository.

HidingCherry avatar Jul 11 '21 08:07 HidingCherry

But that's different than evan's case

His case was to accept short hand build containing string.

You cases is to add support for git repo. I have a question where does docker-compose clone it? And what is the name of the directory?

muayyad-alsadi avatar Jul 11 '21 08:07 muayyad-alsadi

I have no idea, I am not a docker-compose dev. I checked .local/share/containers/ folder, while it was building - but found no src.

HidingCherry avatar Jul 11 '21 10:07 HidingCherry

I have build: . in my config, and I don't even see it trying to build the image. Rather, it looks like it still tries to fetch it from somewhere, and then I get a failure because I'm not authorised to wherever that is.

hakanai avatar Feb 16 '22 03:02 hakanai

@hakanai I think I ran into a similar issue and had to rm the running container if it existed, and delete the previously built image.

evanshortiss avatar Feb 16 '22 06:02 evanshortiss

In the meantime I've learnt a bit more. I think the clone directory is one of the buildah storage containers, there were 6 or 7 the last time I tried to build something.

HidingCherry avatar Feb 16 '22 06:02 HidingCherry