I'm working on a project using Docker Compose, and I've run into an issue while building a Python container. In my Dockerfile, I have the line "RUN sudo apt install unixodbc". However, when I run 'docker-compose up', I'm getting an error message: 'failed to solve: process "/bin/sh -c sudo apt install unixodbc" did not complete successfully: exit code: 127'. Can anyone help me figure out what I'm doing wrong? Here's the current state of my Dockerfile:
FROM python:3.14.3
WORKDIR /.
RUN sudo apt install unixodbc
RUN useradd app
USER app
1 Answer
The problem you're running into is that most Docker images don't come with 'sudo' installed because builds typically start as root. You can just run 'apt install unixodbc' directly without 'sudo'. Also, be aware that using 'apt' in a Dockerfile can lead to some issues with interaction and cleanup, so it's good practice to use additional flags. Check out the Docker best practices for more info!

I tried running it without 'sudo', but I still got the same error. I’ll check the link you provided!