Describe the problem/error/question
Trying to install a package globally; install curl; then install uv via a bash script, all in the docker-compose.yml file.
command: /bin/sh -c "npm install -g n8n-nodes-youtube-transcription && apk --no-cache add curl && curl -LsSf https://astral.sh/uv/install.sh | /bin/sh"
Reading through the doco and some examples online this should’ve worked, but I get the error Error: command /bin/sh not found
Same thing if I remove the /bin/sh component and go straight to npm - it complains that npm can’t be found.
I thought maybe the command was too complex, so I tried the example in the official docs and that returned the same error Error: command /bin/sh not found
. This was the command from the docs:
command: /bin/sh -c 'echo "hello $$HOSTNAME"'
What is the error message (if any)?
Error: command /bin/sh not found
Error: command sh not found
Error: command npm not found
Please share your workflow
N/A
Share the output returned by the last node
N/A
Information on your n8n setup
- n8n version: 1.82.3
- Database (default: SQLite): Default
- n8n EXECUTIONS_PROCESS setting (default: own, main): Default
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: Windows 11 Pro
Hi @bluedog,
Thanks for the detailed info — super helpful.
You’re seeing Error: command /bin/sh not found
and similar issues like npm not found
because of how you’re using the command:
in your docker-compose.yml
. This field overrides the default container entrypoint, so unless you explicitly load the shell environment properly, it can fail hard — especially if you’re trying to chain commands like npm
, apk
, or curl
.
Recommended Fix
Instead of using command:
, use the Dockerfile
to install your dependencies cleanly. Here’s how:
1. Create a Dockerfile
FROM n8nio/n8n:1.82.3
# Install required tools
USER root
RUN apk --no-cache add curl \
&& npm install -g n8n-nodes-youtube-transcription \
&& curl -LsSf https://astral.sh/uv/install.sh | sh
# Switch back to n8n user
USER node
2. Update your docker-compose.yml
to build this image
version: "3.8"
services:
n8n:
build:
context: .
dockerfile: Dockerfile
ports:
- "5678:5678"
environment:
- DB_TYPE=sqlite
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=admin
volumes:
- .n8n:/home/node/.n8n
Why this works better:
command:
overrides how the container starts, not just what it does — so it breaks the base image’s startup scripts.
- Building your own image using
Dockerfile
keeps everything modular, reproducible, and avoids shell errors.
- This lets you install anything before n8n launches properly.
Let me know if you want a version that installs uv
or npm
packages dynamically via an init script or volume mount — there are other ways to handle that too.
I hope this helps.
1 Like
Thanks for that, I haven’t got a lot of experience with Docker so wasn’t aware I could do it in that way.
The fix has only partially worked - curl and the npm package get installed, but the command to curl the .sh script and pipe to sh doesn’t seem to have run, even though it runs perfectly fine when done post-boot.
Any idea why that last command to curl the .sh script to /bin/sh failed? Given curl installed correctly and was the first command in the RUN sequence, I don’t see why there was an issue with that command being run.
Also if you have a more straightforward way of installing uv, I’d be grateful to see it. I’ve had to resort to this as I’m running Alpine on WSL and the package gives segmentation faults when installed via apk for some reason.
My dockerfile:
FROM n8nio/n8n
USER root
RUN apk --no-cache add curl \
&& npm install -g n8n-nodes-youtube-transcription \
&& curl -LsSf https://astral.sh/uv/install.sh | /bin/sh
USER node
My docker-compose.yml:
version: "3.7"
services:
n8n:
build:
context: .
dockerfile: dockerfile.dockerfile
restart: always
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- GENERIC_TIMEZONE=Australia/Canberra
- NODE_FUNCTION_ALLOW_EXTERNAL=*
volumes:
- n8n_data:/home/node/.n8n
- "C:/Users/user/Documents/Docker\ Projects/n8n/n8n-local-files:/files"
volumes:
traefik_data:
external: true
n8n_data:
external: true
The output of the docker compose command:
C:\Users\user\Documents\Docker Projects\n8n>docker compose up -d
time="2025-03-24T22:02:03+11:00" level=warning msg="C:\\Users\\user\\Documents\\Docker Projects\\n8n\\docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"
[+] Building 14.0s (7/7) FINISHED docker:desktop-linux
=> [n8n internal] load build definition from dockerfile.dockerfile 0.0s
=> => transferring dockerfile: 235B 0.0s
=> [n8n internal] load metadata for docker.io/n8nio/n8n:latest 1.9s
=> [n8n internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [n8n 1/2] FROM docker.io/n8nio/n8n:latest@sha256:5288543ac4dc1ea7149a93e38a24989c913c9007dd2459f6c730a 0.0s
=> [n8n 2/2] RUN apk --no-cache add curl && npm install -g n8n-nodes-youtube-transcription && curl -LsS 11.0s
=> [n8n] exporting to image 0.8s
=> => exporting layers 0.8s
=> => writing image sha256:5c095316b86f77007a5e919b1266ca3b81f1e466df71ded0373e3e7ff7000145 0.0s
=> => naming to docker.io/library/n8n-n8n 0.0s
=> [n8n] resolving provenance for metadata file 0.0s
[+] Running 2/2
✔ n8n Built 0.0s
✔ Network n8n_default Created 0.4s
✔ n8n Built 0.0s
✔ Network n8n_default Created 0.4s
✔ Container n8n-n8n-1 Started 0.8s
I understand you’re encountering issues with your Docker setup on Alpine Linux, specifically with the execution of a shell script during the build process and segmentation faults when installing certain packages via apk
. Let’s address these concerns:
1. Shell Script Execution During Docker Build:
Piping a script directly from curl
into sh
within a Docker RUN
command can sometimes lead to unexpected behavior. This is often due to how the shell interprets the piped input during the image build process. To mitigate this, consider downloading the script first and then executing it:
FROM n8nio/n8n
USER root
RUN apk --no-cache add curl \
&& npm install -g n8n-nodes-youtube-transcription \
&& curl -LsSf https://astral.sh/uv/install.sh -o /tmp/install_uv.sh \
&& sh /tmp/install_uv.sh \
&& rm /tmp/install_uv.sh
USER node
This approach ensures that the script is fully downloaded before execution, reducing the risk of partial downloads or execution issues.
2. Segmentation Faults with apk
on Alpine Linux:
Experiencing segmentation faults when installing packages via apk
on Alpine Linux, especially under WSL, is a known issue. These faults can arise from compatibility problems between Alpine’s musl
libc implementation and certain packages or system environments.
One documented instance involves segmentation faults occurring after upgrading from Alpine 3.17 to 3.18 on armv7l
architectures, traced back to issues with musl
.
Recommendations:
-
Use Official Packages When Possible: If uv
or its equivalent is available in Alpine’s official repositories, prefer installing it via apk
to ensure compatibility.
-
Verify Script Compatibility: Ensure that the script you’re executing is compatible with Alpine’s musl
libc. Some scripts or binaries precompiled against glibc
may not function correctly on Alpine.
-
Consult Alpine and WSL Communities: Given the unique combination of Alpine on WSL, reaching out to both communities can provide insights into known issues and potential fixes.
By implementing the above adjustments and considerations, you should achieve a more stable Docker build environment on Alpine Linux under WSL.