slimtoolkit / slimtoolkit/slim

`--mount` option problem for building Postgres image

Open
#331 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
Go
Stars
23.4k
Forks
840
PR merge metrics
No merged PRs in 30d

Description

Expected Behavior

Running pgbench benchmark on PostgreSQL as a probe should be enough for docker-slim to create a minified image which can handle same load. Creating a database, filling it with some data and running some concurrent queries is what pgbench do.


Actual Behavior

But after building slim image some odd behavior appear:

  • Postgres image (specially on alpine) isn't minified.
  • docker-slim doesn't respect --mount and --exclude-mounts, generated image still has files in mounted volume location.
  • Some log showing artifact sensor facing don't exist problem and missing in rawNames

Steps to Reproduce the Problem

docker-slim build \
    --target postgres:14.3-alpine \
    --env POSTGRES_HOST_AUTH_METHOD=trust \
    --show-clogs=true \
    --http-probe=false \
    --mount pgdata:/var/lib/postgresql/data/ \
    --exclude-mounts \
    --exec "pgbench -i -U postgres -s 10 postgres && pgbench -U postgres -c 10 -t 2000 postgres && psql -U postgres postgres -c 'DROP TABLE pgbench_accounts, pgbench_branches, pgbench_tellers, pgbench_history;'"

log file is attached.

for testing minified image run this docker-compose:

version: '3.3'
services:
  postgres:
    image: postgres.slim:latest
    environment:
      POSTGRES_HOST_AUTH_METHOD: trust
  tester:
    image: postgres:14.3
    entrypoint:
      - bash
      - -c
      - "sleep 3; pgbench -i -U postgres -h postgres -s 50 postgres && pgbench -U postgres -h postgres -c 30 -t 10000 postgres"

Postgres exits with this error:

PostgreSQL Database directory appears to contain a database; Skipping initialization
FATAL:  58P01: could not open directory "/usr/local/lib/postgresql": No such file or directory

Specifications

  • Version: docker-slim version linux|Transformer|1.37.6|26a36c88a94c677efd734e874ba081dabb84a224|2022-04-23_06:03:56AM
  • Platform: Ubuntu 18.04.6 LTS, docker-slim ran on host (not in a container)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided docker-slim build command and inspect the attached postgres.log, focusing on --mount, --exclude-mounts, and the artifact sensor messages. Done means the PostgreSQL image is minified, mounted-volume files are excluded, and the resulting image can run the supplied pgbench docker-compose workload without the missing-directory error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go, postgresql
Domain
databases, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.