Multi-Platform Docker Images Interfering With Each Other During Build

I’m trying to build Postgres Docker images for both amd64 & arm64 with a pre-populated database of AU addresses; using an M2 MacBook with Docker Engine 27.4.0.

When the build gets to the stage of running pg_restore to load the data in both images; I get duplicated ID failures creating primary keys. These IDs are not duplicated in the dump files (they’re used by many users and I’ve loaded them myself without issue – FYI see https://github.com/minus34/gnaf-loader for info on the data itself)

I can only conclude the databases in the 2 images are interfering with each other, even though they should be running on their own internal port 5432.

Build code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>!/usr/bin/env bash
# 1. launch buildx
docker buildx create --name gnafloader_test_builder --use
docker buildx inspect --bootstrap
# 2. build images
docker buildx build --no-cache --platform linux/arm64,linux/amd64 --tag minus34/gnafloader_test:latest --tag minus34/gnafloader_test:202411 -f ${DOCKER_FOLDER}/Dockerfile . --load
</code>
<code>!/usr/bin/env bash # 1. launch buildx docker buildx create --name gnafloader_test_builder --use docker buildx inspect --bootstrap # 2. build images docker buildx build --no-cache --platform linux/arm64,linux/amd64 --tag minus34/gnafloader_test:latest --tag minus34/gnafloader_test:202411 -f ${DOCKER_FOLDER}/Dockerfile . --load </code>
!/usr/bin/env bash 
            
# 1. launch buildx
docker buildx create --name gnafloader_test_builder --use
docker buildx inspect --bootstrap
            
# 2. build images
docker buildx build --no-cache --platform linux/arm64,linux/amd64 --tag minus34/gnafloader_test:latest --tag minus34/gnafloader_test:202411 -f ${DOCKER_FOLDER}/Dockerfile . --load

Dockerfile excerpt:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>FROM debian:bookworm-slim
# install Postgres with PostGIS
...
# copy and restore GNAF & Admin Boundary Postgres dump files
RUN mkdir -p /data
WORKDIR /data
ADD gnaf-202411.dmp .
ADD admin-bdys-202411.dmp .
RUN /etc/init.d/postgresql start
&& pg_restore -Fc -d postgres -h 127.0.0.1 -p 5432 -U postgres /data/gnaf-202411.dmp
&& /etc/init.d/postgresql stop
&& rm /data/gnaf-202411.dmp
RUN /etc/init.d/postgresql start
&& pg_restore -Fc -d postgres -h 127.0.0.1 -p 5432 -U postgres /data/admin-bdys-202411.dmp
&& /etc/init.d/postgresql stop
&& rm /data/admin-bdys-202411.dmp
# enable external access to postgres - WARNING: these are insecure settings! Edit these to restrict access
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/16/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/16/main/postgresql.conf
EXPOSE 5432
# set user for postgres startup
USER postgres
# Start postgres when starting the container
CMD ["/usr/lib/postgresql/16/bin/postgres", "-D", "/var/lib/postgresql/16/main", "-c", "config_file=/etc/postgresql/16/main/postgresql.conf"]
</code>
<code>FROM debian:bookworm-slim # install Postgres with PostGIS ... # copy and restore GNAF & Admin Boundary Postgres dump files RUN mkdir -p /data WORKDIR /data ADD gnaf-202411.dmp . ADD admin-bdys-202411.dmp . RUN /etc/init.d/postgresql start && pg_restore -Fc -d postgres -h 127.0.0.1 -p 5432 -U postgres /data/gnaf-202411.dmp && /etc/init.d/postgresql stop && rm /data/gnaf-202411.dmp RUN /etc/init.d/postgresql start && pg_restore -Fc -d postgres -h 127.0.0.1 -p 5432 -U postgres /data/admin-bdys-202411.dmp && /etc/init.d/postgresql stop && rm /data/admin-bdys-202411.dmp # enable external access to postgres - WARNING: these are insecure settings! Edit these to restrict access RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/16/main/pg_hba.conf RUN echo "listen_addresses='*'" >> /etc/postgresql/16/main/postgresql.conf EXPOSE 5432 # set user for postgres startup USER postgres # Start postgres when starting the container CMD ["/usr/lib/postgresql/16/bin/postgres", "-D", "/var/lib/postgresql/16/main", "-c", "config_file=/etc/postgresql/16/main/postgresql.conf"] </code>
FROM debian:bookworm-slim

# install Postgres with PostGIS

...

# copy and restore GNAF & Admin Boundary Postgres dump files
RUN mkdir -p /data
WORKDIR /data

ADD gnaf-202411.dmp .
ADD admin-bdys-202411.dmp .

RUN /etc/init.d/postgresql start 
    && pg_restore -Fc -d postgres -h 127.0.0.1 -p 5432 -U postgres /data/gnaf-202411.dmp 
    && /etc/init.d/postgresql stop 
    && rm /data/gnaf-202411.dmp

RUN /etc/init.d/postgresql start 
    && pg_restore -Fc -d postgres -h 127.0.0.1 -p 5432 -U postgres /data/admin-bdys-202411.dmp 
    && /etc/init.d/postgresql stop 
    && rm /data/admin-bdys-202411.dmp   

# enable external access to postgres - WARNING: these are insecure settings! Edit these to restrict access
RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/16/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/16/main/postgresql.conf

EXPOSE 5432

# set user for postgres startup
USER postgres

# Start postgres when starting the container
CMD ["/usr/lib/postgresql/16/bin/postgres", "-D", "/var/lib/postgresql/16/main", "-c", "config_file=/etc/postgresql/16/main/postgresql.conf"]

Is there any way to avoid this using Docker BuildX or should I try Podman?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật