docker-maven-plugin icon indicating copy to clipboard operation
docker-maven-plugin copied to clipboard

Podman not supported

Open kb-1000 opened this issue 4 years ago • 21 comments

Description

Info

  • d-m-p version : 0.28.0
  • Maven version (mvn -v) :
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: /home/kb1000/.m2/wrapper/dists/apache-maven-3.6.2-bin/795eh28tki48bv3l67maojf0ra/apache-maven-3.6.2
Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.fc31.x86_64/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "5.5.6-201.fc31.x86_64", arch: "amd64", family: "unix"
  • Docker version : none, emulated using podman 1.8.0 from Fedora 31
  • If it's a bug, how to reproduce : Install podman on Fedora 31 using sudo dnf install podman-docker and try to use this Maven plugin
  • If it's a feature request, what is your use case :
  • Sample project : https://github.com/quarkusio/quarkus-quickstarts (tested with hibernate-search-elasticsearch-quickstart project there)
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.28.0:stop (docker-start) on project hibernate-search-elasticsearch-quickstart: Execution docker-start of goal io.fabric8:docker-maven-plugin:0.28.0:stop failed: No <dockerHost> given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[kb1000@local-host hibernate-search-elasticsearch-quickstart]$ docker
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Error: missing command 'podman COMMAND'
Try 'podman --help' for more information.

kb-1000 avatar Mar 01 '20 16:03 kb-1000

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

rhuss avatar Mar 02 '20 07:03 rhuss

Agreed, but will it get added?

kb-1000 avatar Mar 09 '20 10:03 kb-1000

There a no plans yet.

rhuss avatar Mar 12 '20 14:03 rhuss

What is needed from Podman to make this work?

rhatdan avatar May 26 '20 14:05 rhatdan

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

rohanKanojia avatar May 26 '20 15:05 rohanKanojia

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.

kb-1000 avatar May 27 '20 05:05 kb-1000

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

  • Building container images by using Docker REST API directly from the the plugin. Abstracting that build part has been started in #1116 but that work has been stopped end of 2018 due to lack of having enough spare time :). The focus in the meantime has been moved to JKube which formerly relied on this plugin for the build part but since then moved on to add support for more build system (e.g. Jib). I highly would recommend to follow on those projects as it is not likely that dmp will get many more feature if we don't find a new ownership (I plan to retire from the project towards the end of this year, tbh, as I don't have time (nor a mandat) for substantially working on this project). An announcement will follow soon. For the build part, support for Buildah would be the perfect replacementn for Docker.

  • Running containers, especially for Maven driven integration tests. This is where Podman comes into the picture. For the reasons mentioned above and because I think Testcontainers is nowadays a much better option for running containers from within Maven (better community support, more platforms supported ootb, ..), Podman support in docker-maven-plugin is very unlikely (at least from my POV, but course could change if the leadership of docker-maven-plugin would be picked up by someone else). A similar abstraction like a RunService (as implemented for a BuildService in #1116) would be needed to switch betwewen docker run and podman run.

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.

rhuss avatar Jun 04 '20 08:06 rhuss

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.

kb-1000 avatar Jun 04 '20 15:06 kb-1000

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.

rhuss avatar Jun 04 '20 16:06 rhuss

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

rhatdan avatar Jun 04 '20 17:06 rhatdan

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 ...

zakkak avatar Jul 13 '20 20:07 zakkak

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).

rhuss avatar Jul 22 '20 05:07 rhuss

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?

gimbrogno avatar Jul 22 '20 13:07 gimbrogno

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:

  • Configuration
    • docker daemon stopped
    • podman installed and running service as per above
    • calling syndesis cli command -> syndesis build -c -f -m meta --docker (the --docker executes the fabric8-maven-plugin in kubernetes mode)
  • Results

phantomjinx avatar Jul 31 '20 22:07 phantomjinx

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

Danipiario avatar Sep 08 '20 16:09 Danipiario

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 ?

rhuss avatar Sep 09 '20 07:09 rhuss

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;
}

wardev avatar Sep 10 '20 13:09 wardev

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.

rhuss avatar Sep 14 '20 13:09 rhuss

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.

Sanne avatar Jan 06 '21 13:01 Sanne

Excellent.

rhatdan avatar Jan 06 '21 15:01 rhatdan

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

Sanne avatar Jul 02 '21 10:07 Sanne

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.

michaelmejaeger avatar Dec 19 '22 14:12 michaelmejaeger

Please open an issue against podman.

rhatdan avatar Dec 19 '22 21:12 rhatdan

Please open an issue against podman.

Done: #1625

michaelmejaeger avatar Dec 27 '22 13:12 michaelmejaeger

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

rohanKanojia avatar Dec 27 '22 14:12 rohanKanojia

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

michaelmejaeger avatar Jan 02 '23 07:01 michaelmejaeger

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.

Sanne avatar May 17 '23 11:05 Sanne