Search code examples
ubuntudocker-composepodman

Docker Compose can not build with Podman


Docker compose will work with podman if I pull images for the services but will not work when I attempt to build an image.

Dockerfile

FROM docker.io/hello-world


$ docker build --tag uscm5 .
STEP 1: FROM docker.io/hello-world
STEP 2: COMMIT uscm5
--> d1165f22123
Successfully tagged localhost/uscm5:latest
Successfully tagged docker.io/library/hello-world:latest
d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726

docker-compose.yml

With the image config rather than the build, it works just fine.

services:
  web:
    build: .
    # image: docker.io/hello-world 


$ docker-compose up
Building web
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 203, in perform_command
  File "compose/metrics/decorator.py", line 18, in wrapper
  File "compose/cli/main.py", line 1186, in up
  File "compose/cli/main.py", line 1182, in up
  File "compose/project.py", line 664, in up
  File "compose/service.py", line 364, in ensure_image_exists
  File "compose/service.py", line 1133, in build
  File "compose/service.py", line 1943, in build
  File "subprocess.py", line 800, in __init__
  File "subprocess.py", line 1551, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'docker': 'docker'
[579202] Failed to execute script docker-compose

My env and program versions seem correct:

$ docker-compose -v && podman -v && lsb_release -r
docker-compose version 1.29.2, build 5becea4c
podman version 3.2.3
Release:        21.04

$ printenv | grep -e DOCKER -e COMPOSE
DOCKER_HOST=unix:///run/user/1000/podman/podman.sock

What am I missing?


Solution

  • Setting COMPOSE_DOCKER_CLI_BUILD=0 is where its at - thank you @Luap99 at GitHub. https://github.com/containers/podman/issues/11052

    Docker Composes uses the Docker CLI rather than the socket at DOCKER_HOST. Perhaps I wouldn't have noticed if I would have alias docker=podman but with COMPOSE_DOCKER_CLI_BUILD=0 will use the docker client rather than the CLI.