dimitri / pgcopydb

Copy a Postgres database to a target Postgres server (pg_dump | pg_restore on steroids)
Other
1.19k stars 78 forks source link

problem with docker image `dimitri/pgcopydb:v0.17` ? #866

Open danstoner opened 3 months ago

danstoner commented 3 months ago

I get "exec format error" when trying to run the latest docker image.

$ docker run --network=host --rm -it dimitri/pgcopydb:v0.17 pgcopydb --help
standard_init_linux.go:180: exec user process caused "exec format error"

This works fine with previous versions (v0.16, v0.15, ...).

$ docker run --network=host --rm -it dimitri/pgcopydb:v0.15 pgcopydb --help
17:19:32.985 1 INFO   Running pgcopydb version 0.15 from "/usr/local/bin/pgcopydb"
pgcopydb: pgcopydb tool
usage: pgcopydb [ --verbose --quiet ]

Available commands:
  pgcopydb
    clone     Clone an entire database from source to target
    fork      Clone an entire database from source to target
...

Docker is supposed to handle all that platform stuff automatically. By using docker inspect I see that the image getting pulled was built for 'arm64' even though I am running this command on Intel hardware. My docker is apparently so old I don't have the pull --platform option or manifest options.

So, moved on to an Intel MacBook with newer docker installed, I can see the following:

$ docker pull --platform linux/amd64  dimitri/pgcopydb:v0.17
$ docker run --network=host --rm -it dimitri/pgcopydb:v0.17 pgcopydb --help
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested

So I think something is wrong in the docker repo where it is always serving the arm64 image.

thomasstxyz commented 3 months ago

I'm currently facing the same problem. I'm using the image as a runtime container for a GitHub Workflow.

Do you know the issue? @dimitri

hanefi commented 3 months ago

There is only one docker image for v1.7 with OS/ARCH pair of linux/arm64/v8.

In earlier releases, we had only linux/amd64, and it changed in the last release for some reason.

See the relevant docker hub page

dimitri commented 2 months ago

Is there anything we should be doing about that issue then?

thomasstxyz commented 2 months ago

Yes, in my opinion, the container registry at dimitri/pgcopydb should host images for both platforms (linux/amd64, linux/arm64/v8).

dimitri commented 2 months ago

We do not have automated builds on dockerhub, and my attempts to build for linux/amd64 from my current laptop are failing, all I seem to be able to get is an image for linux/arm64. Help?

thomasstxyz commented 2 months ago

Oh I see. So the issue would be resolved if we add automated image build and push to Docker Hub here https://github.com/dimitri/pgcopydb/blob/main/.github/workflows/docker-publish.yml ? As far as I see it's only configured to push to GitHub Container Registry, at the moment.

mldisibio commented 2 months ago

As a workaround I was able to get an amd64 image using docker pull --platform linux/amd64 ghcr.io/dimitri/pgcopydb:latest but I also usually pull from docker hub, so had to also change my docker scripts for the image name and tag.

danstoner commented 2 months ago

@dimitri

From a Medium article:

The Docker documentation describes how this can be accomplished https://docs.docker.com/engine/reference/builder/#from using the --platform argument with the FROM command.

This will tell Docker to specifically build for linux/amd64 when it is generating the image and now your image that is being built on MacOS will be compatible and deployable to ECS/EKS.

So, for example, in Dockerfile.debian I think changing the first line:

FROM debian:sid

to:

FROM --platform=linux/amd64 debian:sid

might build the non-ARM version.

You mentioned:

my attempts to build for linux/amd64 from my current laptop are failing

Can you elaborate?

thomasstxyz commented 2 months ago

I'm pretty sure what is missing here is just the GitHub Workflow, which pushes the image to both GHCR and DockerHub.

If you can not find anyone, I could also contribute this feature.