Reputation: 561
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
Reputation: 2427
by default docker container runs as root user
remove the sudo from Dockerfile and run again.
Upvotes: 56
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
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