Unable to use sudo commands within Docker, "bash: sudo: command not found" is displayed

DockerSudoTensorflow Serving

Docker Problem Overview


I have installed TensorFlow using the following command

docker run -it b.gcr.io/tensorflow/tensorflow:latest-devel

and I need to set up TensorFlow Serving on a windows machine. I followed the instructions and while running the below-mentioned sudo command while installing TensorFlow Serving dependencies:

sudo apt-get update && sudo apt-get install -y \
     build-essential \
     curl \
     git \
     libfreetype6-dev \
     libpng12-dev \
     libzmq3-dev \
     pkg-config \
     python-dev \
     python-numpy \
     python-pip \
     software-properties-common \
     swig \
     zip \
     zlib1g-dev

The following error is displayed:

bash: sudo: command not found

Docker Solutions


Solution 1 - Docker

docker comes along with root it doesnt require sudo.

BTW if you want sudo in docker if you want to install sudo,

try this,

apt-get update && \
      apt-get -y install sudo

now you can use sudo along with your command in docker...

Solution 2 - Docker

Docker images typically do not have sudo, you are already running as root by default. Try

apt-get update && apt-get install -y build-essential curl git libfreetype6-dev libpng12-dev libzmq3-dev pkg-config python-dev python-numpy python-pip software-properties-common swig zip zlib1g-d

If you wish to not run as root, see the Docker documentation on the User command.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVasantiView Question on Stackoverflow
Solution 1 - DockerMohideen bin MohammedView Answer on Stackoverflow
Solution 2 - DockerSam MyersView Answer on Stackoverflow