The scenario

Situation
A self-hosted container registry (Harbor, run with Docker Compose) would not start; docker-compose crashed immediately, and the services also failed to come back after every server restart.
Environment
Hardened RHEL server with /tmp mounted noexec; Harbor deployed with Docker Compose under root.
Goal
Get the registry running again, then make it come back on its own after reboots without manual steps.
Outcome
Registry restored; after adding a systemd unit, all Harbor containers start automatically after a reboot.

The registry was down, and the first command anyone would run failed straight away:

# docker-compose up -d
docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object

The message points at libz.so.1, so the natural reaction is to reinstall zlib. That would not have fixed anything.

Why it happens

The standalone docker-compose binary (Compose v1) is a self-extracting bundle. Each time it runs, it unpacks its own copies of shared libraries, including libz.so.1, into a temporary directory under $TMPDIR, which defaults to /tmp, and then loads them.

On a hardened server, /tmp is commonly mounted with noexec. Loading a shared library needs to map it into memory as executable, and noexec forbids exactly that. The loader therefore fails with “failed to map segment from shared object”. The library is fine; the place it was unpacked to is not allowed to hold executable code.

Confirm it in a few seconds:

findmnt -no OPTIONS /tmp      # look for "noexec"

Fix 1: give docker-compose an executable temp directory

Point TMPDIR at a directory on a filesystem without noexec. I used the Harbor install directory, which root already owns:

# /root/.bash_profile
export TMPDIR=/root/harbor
alias docker-compose="TMPDIR=/root/harbor docker-compose"

Then, in a fresh root login:

cd /root/harbor
docker-compose up -d
docker-compose ps            # all containers should show "Up" / "healthy"

Verify by opening the registry’s web UI and signing in as a normal user.

This fixes interactive use only. A profile file is read by login shells, not by anything that starts at boot, which leads to the second problem.

Fix 2: make it start on its own after every reboot

The registry also failed to come back after each server restart, because nothing started the Compose stack at boot. A small systemd unit solves both problems at once: it sets TMPDIR itself and runs at startup.

# /etc/systemd/system/harbor-compose.service
[Unit]
Description=Harbor container registry (Docker Compose)
Requires=docker.service
After=docker.service network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/root/harbor
Environment=TMPDIR=/root/harbor
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now harbor-compose.service
systemctl status harbor-compose.service

Why these settings:

After a test reboot, the status showed every container (registry, redis, core, job service, scanner adapter, nginx) started automatically:

● harbor-compose.service - Harbor container registry (Docker Compose)
     Loaded: loaded (/etc/systemd/system/harbor-compose.service; enabled)
     Active: active (exited)
    Process: ExecStart=/usr/bin/docker compose up -d (code=exited, status=0/SUCCESS)

Takeaways