I'm currently building a project using a Docker Compose file, and I'm running into an issue with installing unixodbc in the Python Docker container. In my Dockerfile, I have the command "RUN sudo apt install unixodbc". However, when I execute 'docker compose up', I receive an error message stating: 'failed to solve: process "/bin/sh -c sudo apt install unixodbc" did not complete successfully: exit code: 127'. I would appreciate any insights or solutions for this! Here's a snippet of my Dockerfile for reference:
FROM python:3.14.3
WORKDIR /.
RUN sudo apt install unixodbc
RUN useradd app
USER app
3 Answers
Exit code 127 usually indicates a command not found error. You may want to check your $PATH to ensure it includes the directories where commands like 'apt' are located. That might help in troubleshooting the issue!
Just a heads up, if you are using an Alpine-based image (which the python:3.14.3 tag might be), it doesn't use apt at all. Instead, Alpine uses apk for package management. If that’s the case, try this command instead: 'RUN apk add --no-cache unixodbc'. If you're looking for a Debian-based image that uses apt, consider using a different tag like debian or slim.
It looks like you're facing an issue because most Docker images don't have sudo installed, and when you're building a Docker image, you're already running as the root user. So, you can simply remove 'sudo' and just run 'RUN apt install unixodbc'. Also, keep in mind that using apt in a Dockerfile often requires some extra flags to avoid prompts and to clean up afterwards. You can find more about those best practices in the official Docker documentation.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically