docker-maven-plugin
docker-maven-plugin copied to clipboard
Podman not supported
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.
True, but that's not a bug. Just a missing feature.
Agreed, but will it get added?
There a no plans yet.
What is needed from Podman to make this work?
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
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.
@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 aBuildService
in #1116) would be needed to switch betwewendocker run
andpodman 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.
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.
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.
Podman 2.0 which is in release candidate stage now supports the REST API of the docker daemon.
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 ...
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).
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 [
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:
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
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 ?
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;
}
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.
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.
Excellent.
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
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
.
Please open an issue against podman.
Please open an issue against podman.
Done: #1625
@michaelmejaeger : I think Daniel meant creating an issue in this repository https://github.com/containers/podman
Ah, sorry, I got that wrong. I will correct that!
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.