How to install standard system commands for amazon-linux 2
Asked Answered
S

1

11

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.

Solitaire answered 13/9, 2019 at 9:15 Comment(4)
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 yumBlanton
Thanks, that's pretty crazy to me. Didn't realise you just used yum to install these regular commands. I feel a bit silly now. Pop that into an answer and I'll mark it as correct @BlantonSolitaire
You pretty much never need sudo in Docker. A container usually runs some single process as a foreground job without user intervention, so you don't usually need an interactive shell in a container, and if you do, you can always docker exec -u 0 to be root.Iene
I need sudo for sudo -u, not for root permissions. Also in my case I use a docker container as a cli quite often since it has everything I need for the command line installed. Plenty runs in the background and it's often interactive. I also need sudo because prod uses sudo in some scripts, those same scripts need to work on my local.Solitaire
B
11

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

Blanton answered 13/9, 2019 at 9:30 Comment(2)
RUN yum -y update && yum install -y sudo worked for me.Heroine
Also need yum install -y whichDevlen

© 2022 - 2024 — McMap. All rights reserved.