fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.86k stars 635 forks source link

Podman not supported #1330

Closed kb-1000 closed 1 year ago

kb-1000 commented 4 years ago

Description

Info

rhuss commented 4 years ago

True, but that's not a bug. Just a missing feature.

kb-1000 commented 4 years ago

Agreed, but will it get added?

rhuss commented 4 years ago

There a no plans yet.

rhatdan commented 4 years ago

What is needed from Podman to make this work?

rohanKanojia commented 4 years ago

I'm not sure whether it's in DMP's roadmap to add Podman support in the future. But we do have plans to support Podman[0] in Eclipse JKube(next generation of FMP/~DMP~)[1]

[0] https://github.com/eclipse/jkube/issues/66 [1] https://github.com/eclipse/jkube

kb-1000 commented 4 years ago

Unfortunately this doesn't help me (or at least I can't see how it would help me), as DMP is the thing used by the Quarkus framework for Docker calls, and using Docker is not always optional there and enabled by default for some of the examples.

rhuss commented 4 years ago

@rhatdan docker-maven-plugin has two major parts:

Said all that, I'm totally open and supportive for PRs would want to tackle and would help to integrate them. But I won't be able to dedicate a considerable amount working effort in dmp.

kb-1000 commented 4 years ago

It's not even necessary to switch between docker run and podman run, the packages (or at least some packages) include a wrapper or a symlink literally called docker. However, if you use the API directly, that obviously won't help.

rhuss commented 4 years ago

However, if you use the API directly, that obviously won't help.

That's the point, this plugin does not user the docker cli but talks directory with the Docker daemon via its REST API.

rhatdan commented 4 years ago

Podman 2.0 which is in release candidate stage now supports the REST API of the docker daemon.

zakkak commented 4 years ago

FWIW the plugin now seems to work (at least partially) with podman >=2.0.

To make it work as a non-root user do:

podman service -t 3600 & # This will start podman's REST API and keep it alive for 1 hour (3600 seconds)
export DOCKER_HOST="export DOCKER_HOST="unix:/run/user/$(id -u)/podman/podman.sock"
mvn ...
rhuss commented 4 years ago

As an idea, we could add support for starting (and stopping) the Podman service transparently, similar like the support we have for docker-machine (see the docs).

gimbrogno commented 4 years ago

Hi I'm using podman-docker and docker maven plugin v0.31.0 to run docker:build but I have an error from rest api: [ERROR] DOCKER> Unable to build image []: {"cause":"Content-Type: application/json is not supported. Should be \"application/x-tar\"","message":"Failed to parse query parameter 'Content-Type': \"application/json\": Content-Type: application/json is not supported. Should be \"application/x-tar\"","response":400} (Bad Request: 400) Any idea to manage docker:build?

phantomjinx commented 3 years ago

Hi I'm using podman-docker and docker maven plugin v0.31.0 to run docker:build but I have an error from rest api: [ERROR] DOCKER> Unable to build image []: {"cause":"Content-Type: application/json is not supported. Should be "application/x-tar"","message":"Failed to parse query parameter 'Content-Type': "application/json": Content-Type: application/json is not supported. Should be "application/x-tar"","response":400} (Bad Request: 400) .....

Encountered same error here while trying out the podman system service -t 3600 workaround. Presumably the podman socket is expected a tar archive whilst the content from the docker-maven-plugin is producing json??

In case it helps, I ran into it while experimenting with replacing docker with podman in syndesis:

Danipiario commented 3 years ago

Hi I'm using podman-docker and docker maven plugin v0.31.0 to run docker:build but I have an error from rest api: [ERROR] DOCKER> Unable to build image []: {"cause":"Content-Type: application/json is not supported. Should be "application/x-tar"","message":"Failed to parse query parameter 'Content-Type': "application/json": Content-Type: application/json is not supported. Should be "application/x-tar"","response":400} (Bad Request: 400) Any idea to manage docker:build?

Same error for me. With "podman system service" and DOKER_HOST set

rhuss commented 3 years ago

Looks like a mismatch in the content-type when uploading the build context to the daemon. Should be easy to fix (assuming that Docker also works with x-tar as content type). Fancy to do a pull request ?

wardev commented 3 years ago

I ended up putting nginx between d-m-p and podman to change some of the settings. I was able to successfully build an image and save it to a tar file. I was unable to run it using d-m-p. Below is the Nginx config file I used. The first issue is the content type you already noted. Docker seems to ignore the content type. The second is that podman only seems to include the version header in calls to _ping whereas Docker includes it in every response. This causes d-m-p to be confused about the version. So I had nginx add the adder to all responses.

server {
    listen localhost:8001;
    location /v1.40/build {
        proxy_pass http://localhost:8880/v1.40/build;
        proxy_set_header Content-Type application/x-tar;
    }
    location / {
        proxy_pass http://localhost:8880;
    }
    add_header Api-Version 1.40;
    client_max_body_size 0;
}
rhuss commented 3 years ago

I see, thanks for the investigation. Let's tackle Podman support for the next release. At least those two issues should be easy to fix.

Sanne commented 3 years ago

Many thanks for this, it's extremely useful!

Updating instructions though, N.B. both preparations commands have to be adjusted slightly now:

 export DOCKER_HOST="unix:/run/user/$(id -u)/podman/podman.sock"
 podman system service -t 3600 &
 mvn ...

(At least, that's what I need to do on Fedora 33 - running as non-root as well. I have both podman and podman-docker installed)

Additionally, some widely used images attempt to perform operations which are typically not allowed under the more restrictive (good) defaults for podman; in many cases it's enough to update the containers, as many have fixed their images.

for example, postgres:10.5 won't work, but postgres:13.1 works flawlessly.

rhatdan commented 3 years ago

Excellent.

Sanne commented 3 years ago

Updating here since people seem to have bookmarked this place:

Podman evolved a bit, the better command is now:

podman system service --time=0 unix:/run/user/$(id -u)/podman/podman.sock
michaelmejaeger commented 1 year ago

Hi, up to now it worked well for me to use the plugin with Podman using podman system service. However, I encountered the following problem today when using docker:push latest (formatted the output for better readability):

DOCKER> Unable to inspect image [sha256:e9685] : 
{
  "cause": "normalizing name for compat API: sha256:e9685: invalid format: no 64-byte hexadecimal value",
  "message": "normalizing image: normalizing name for compat API: sha256:e9685: invalid format: no 64-byte hexadecimal value",
  "response": 500
}

(Internal Server Error: 500)]

The reason seems to be that the plugin uses 5-byte hex shortcuts while the podman-docker-service requires the full 64-byte hex value.

I am using podman in version 4.3.1 together with the latest plugin version 0.40.3.

rhatdan commented 1 year ago

Please open an issue against podman.

michaelmejaeger commented 1 year ago

Please open an issue against podman.

Done: #1625

rohanKanojia commented 1 year ago

@michaelmejaeger : I think Daniel meant creating an issue in this repository https://github.com/containers/podman

michaelmejaeger commented 1 year ago

Ah, sorry, I got that wrong. I will correct that!

Sanne commented 1 year ago

I would suggest closing this - we've been using podman for a while with this maven plugin and it "just works".

There's of course some differences, but that would be out of scope for this issue.