mspms
mspms

Reputation: 561

/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 http://ifconfig.me/ip

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?

Upvotes: 52

Views: 74568

Answers (3)

Abhishek D K
Abhishek D K

Reputation: 2427

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

enter image description here

Upvotes: 56

Mihai
Mihai

Reputation: 10717

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

Upvotes: 13

vivekyad4v
vivekyad4v

Reputation: 14823

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 http://ifconfig.me/ip

PS - Merge the RUN statements as much as possible.

Upvotes: 9

Related Questions