Unable to Build Docker Ubuntu image on MacOS

I am trying to build a very simple docker file on my Mac(1.6 GHz Dual-Core Intel Core i5/macOS Sonoma 14.7) but the build keeps failing with the below error.

docker build -t simple-image .

Dockerfile

FROM ubuntu:latest

# Update the package list and install the required packages
RUN apt-get update && apt-get install -y \
    curl

# install git jq

# Clean up the package lists to reduce the image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Set the default command to run when the container starts
CMD ["bash"]

Error

   4 | >>> RUN apt-get update && apt-get install -y \
   5 | >>>     curl
   6 |         # sudo 
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y     curl" did not complete successfully: exit code: 100

Thanks
Sam

The second step does not reduce image size, it removes the files from later layers, but they’re still there, committed in the previous layers

If you want to clean up the installations you need to do it in the same layer. Execute the clean and rm commands in the same RUN step using &&


As for the error you’re experiencing, not sure, sorry
Edit: Forgot to mention, @rimelek is right, there’s nothing wrong with the Dockerfile (in terms of errors, my comment still applies) - I have copied it and built the image myself with no problems, so your problem lies elsewhere

There is nothing wrong with the Dockerfile. Run an ubuntu container and execute the commands interactively so you will at least know whihc command gives you the error.and you can investigate why.