/Bin/Sh: 1: Sudo: Not Found When Running Dockerfile

/Bin/Sh: 1: Sudo: Not Found When Running Dockerfile

This is the content of my Dockerfile.

FROM ubuntu

RUN sudo apt-get update

RUN sudo apt-get install -y wget

CMD wget -O- -q 

When I run the Dockerfile to build a docker image, I get the below error:

/bin/sh: 1: sudo: not found

Can you please help me in solving the above error?

5

3 Answers

by default docker container runs as root user
remove the sudo from Dockerfile and run again.

2

Your commands in the Dockerfile already run as root during docker build. For this reason you do not need to use sudo

You don't need sudo in this case. Change Dockerfile as below -

FROM ubuntu

RUN apt-get update -y && \ 
    apt-get install -y wget

CMD wget -O- -q 

PS - Merge the RUN statements as much as possible.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.