Search code examples
dockeramazon-linux

How to install standard system commands for amazon-linux 2


I seem to be missing some very basic utilities, namely the commands sudo and which seem to be missing. How can I install these, or even better is there an ami linux image which has all of these kind of things pre-installed.

Dockerfile:

FROM amazonlinux:2.0.20190823.1-with-sources
RUN echo $(which sudo)

Error:

/bin/sh: which: command not found

Or if I just try to use something like sudo yum

/bin/sh: sudo: command not found

Since it seems relevant, I also don't seem to have root permissions as trying to use the adduser command gives me a non zero response code of 2.


Solution

  • RUN yum update && yum install -y sudo, sudo is not installed in that image by default. you are already root in that images so you do not need sudo yum.

    the idea from not installing too many packages by default ,is to let the image as small as possible and let the user install just what he needs