Arama Yap Mesaj Submit
Request a Callback
+90
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro

Contact Us

Location Halkali merkez neighborhood fatih st ozgur apt no 46 , Kucukcekmece , Istanbul , 34303 , TR
Docker Install Script Exit 141 / SIGPIPE / pipefail Fix
Docker, Bash, pipefail and Ubuntu 24.04

Docker Install Script Exit Code 141 / SIGPIPE: Real pipefail + head Fix

The first version of our real Docker installation script stopped with exit code 141 even though Docker package operations were healthy. Docker Engine was not the root cause: set -o pipefail was enabled and the display-only pipeline 'apt-cache policy docker-ce | head -n 20' caused the upstream command to receive SIGPIPE when head exited early. Replacing it with sed -n allowed the script to continue; the final environment verified Docker 29.7.2 and Compose v5.4.0.

Docker exit 141SIGPIPEpipefailapt-cache policy docker-cehead SIGPIPEbash exit 141Docker install scriptUbuntu 24.04EKA Sunucu
Docker Install Script / Exit 141 / SIGPIPE / pipefail
set -o pipefail
apt-cache policy docker-ce | head -n 20
↓
head exits early
upstream gets SIGPIPE
128 + SIGPIPE(13) = exit 141
↓
apt-cache policy docker-ce | sed -n '1,20p'
↓
script continues
Hata141 / SIGPIPEDüzeltmesed -n
3real WebP screenshots
3TR · EN · DE content
8Teknik bölüm
100%Gerçek ekran görüntüsü
01real exit 141
02pipefail + head cause
03sed -n fix
04final Docker success
00
Table of contents

Docker exit 141 and SIGPIPE troubleshooting steps

  1. 01Why did the script exit 141 while Docker installation looked successful?
  2. 02Why is 141 associated with SIGPIPE?
  3. 03Why did pipefail turn a harmless display pipeline into a script failure?
  4. 04Why was head fragile for display-only output?
  5. 05Why did sed -n '1,20p' fix the script?
  6. 06Verify Docker independently from the wrapper-script failure
  7. 07Why should display-only commands not abort production installers?
  8. 08Docker and Portainer worked normally after the fix
01
Real symptom

Why did the script exit 141 while Docker installation looked successful?

After package installation the script shortened apt-cache policy output with head. With pipefail enabled, the upstream SIGPIPE status made the whole pipeline fail.

So exit 141 did not mean Docker itself failed.

Command 1
set -o pipefail
Command 2
apt-cache policy docker-ce | head -n 20
Command 3
echo $?
02
Exit code

Why is 141 associated with SIGPIPE?

Shells commonly report signal termination as 128 plus the signal number. SIGPIPE is signal 13, so 128 + 13 gives 141.

head closes the pipe after enough lines; an upstream writer may then receive SIGPIPE.

03
Effect of pipefail

Why did pipefail turn a harmless display pipeline into a script failure?

Without pipefail, a pipeline often reports the last command's status. With pipefail, a failing upstream command affects the pipeline status.

Combined with set -e, this can terminate the whole script.

Command 1
set -euo pipefail
05
Real fix

Why did sed -n '1,20p' fix the script?

We replaced the display line with apt-cache policy docker-ce | sed -n '1,20p'. sed can consume the input stream while printing only the requested lines, avoiding the early closed pipe.

This preserved pipefail without the accidental SIGPIPE.

Command 1
apt-cache policy docker-ce | sed -n '1,20p'
06
Did Docker actually install?

Verify Docker independently from the wrapper-script failure

After exit 141, docker --version, docker compose version, service status and hello-world reveal the actual Docker state.

Our real final screen verified Docker 29.7.2 and Compose v5.4.0.

Command 1
docker --version
Command 2
docker compose version
Command 3
systemctl is-active docker
Command 4
docker run --rm hello-world
07
Script design

Why should display-only commands not abort production installers?

Separate informational output from critical installation steps. Do not let a cosmetic pipeline use the same failure policy as package installation.

Use targeted fallbacks when justified, but do not hide real apt/docker failures with blanket || true.

08
Real final

Docker and Portainer worked normally after the fix

After the fix, Docker Engine, Compose and Portainer were verified in real screens. That supports the conclusion that Bash pipeline handling—not Docker Engine—was the root cause.

For similar exit 141 failures, identify the last pipeline executed.

Production checklist

Reliable Bash installation-script checklist

Do not expose private backend ports publicly just to fix the error.
Compare container and service logs before and after changes.
Take a volume backup or VPS snapshot before production changes.
Repeat health and real functional tests after version upgrades.
Verify Docker port bindings with docker ps and ss.
Validate real HTTP/API behavior, not only process status.
Store required secrets and credentials securely and persistently.
Keep deployment logs and a rollback plan for upgrades and fixes.
R
Official sources

Official Docker and Bash resources

+
EKA Sunucu

Related Docker guides

?
FAQ

Frequently asked questions about Docker exit 141, SIGPIPE and pipefail

What does exit 141 mean?

In this case it represents SIGPIPE: 128 + signal 13.

Was Docker broken?

No; the real final checks showed Docker was installed and working.

Which line triggered it?

apt-cache policy docker-ce | head -n 20.

Why does pipefail matter?

It propagates upstream failures into the pipeline status.

What happens with set -e?

The script can terminate when the pipeline returns non-zero.

Why can head cause SIGPIPE?

It closes the pipe after receiving the requested lines.

What was the real fix?

Replace head with sed -n '1,20p'.

Should I add || true?

Not blindly; it can hide real failures.

How do I verify Docker?

Version, Compose, service status and hello-world.

Is exit 141 always caused by head?

No; any pipeline scenario producing SIGPIPE can yield it.

Why is sed more stable here?

It can keep consuming input while printing selected lines.

What should I look for in logs?

The pipeline executed immediately before exit 141.

Could the Docker repository still be broken?

Yes; verify apt update and real package-install results separately.

Can this happen in CI?

Yes, the same pattern can occur in non-interactive Bash with pipefail.

EKA YAZILIM VE BİLİŞİM SİSTEMLERİ

Need an Ubuntu VPS for Docker?

Run Docker and self-hosted services on EKA Sunucu Linux VPS.

Updated: 10.08.2026
View Linux VPS PlansLinux & VPS Guides
Top