2

I'm operating within a Kong API Gateway Docker container, and am trying to install some basic package handling. Ultimately, I need to be able to use sudo. The Docker image comes with only busybox bin commands, located in /bin/.

What I've Tried

I find myself in a pickle, because every guide that explains downloading apt-get uses sudo, and every guide I find downloading sudo uses apt-get. I have neither sudo nor apt and apt-get.

If I try to utilize su, su -, su - <cmd>, or the likes, I get "must be suid to work properly".

What's Available

This is every command available, located in /bin:

list of every command available


With wget, or the above commands, how can I get sudo?

  • 3
    Have you considered editing the Dockerfile to add the sudo package? Err-- nevermind sudo; if you want other packages, can't you just edit the Dockerfile? – Jeff Schaller Mar 16 at 14:49
  • I suppose I could... I'm new to Docker as well, so I'm exec'ing in my container to find out what I need to do with the Dockerfile. Would I just have RUN <install sudo here>? – bananabrann Mar 16 at 14:53
  • Perhaps we can rescue the question by taking it in the right direction. You're operating within a Docker container. Do you have the ability to create a new container? – Jeff Schaller Mar 16 at 14:55
  • I do! I have a Dockerfile with FROM kong:2.0-ubuntu and exposing 5432 – bananabrann Mar 16 at 14:57
  • Yes you can do the install with RUN. However you won't need sudo if you are still root though. Just install and configure, before switching from root. – ctrl-alt-delor Mar 16 at 17:29
6

Even if you got sudo onto your system (easy), it would not help. It needs to be setuid-root to work. And you can't set that up, without root access.

If running the commands without sudo is not working, then it is because the Dockerfile has USER line. If you edit the Dockerfile, to put the apt-get (or the commands to install apt-get) before this line, then it will be able to install (you will still be root).

| improve this answer | |
  • Thanks for the reply! You seem super knowledgeable in this... Is there a way to get sudo in without rebuilding the image? I'm running into some severe issues with Kong's official image, and it would be nice to just bypass that and exec into the container to add and move files around so that I can get my testing environment running for developing plugins – bananabrann Mar 16 at 17:12
  • 1
    Rebuilding images is not as hard as you may think, and if the changes are late on, then they don't even rebuild. Each line of the Dockerfile creates a layer. It will start on an existing layer, and add more. What image are you using? – ctrl-alt-delor Mar 16 at 17:16
  • 2
    you need to put the docker-entrypoint.sh (see github.com/Kong/docker-kong/tree/… ) next to the Dockerfile, then do the docker build. – ctrl-alt-delor Mar 16 at 17:24
  • 1
    I think for the ubunu version (as it leaves you as root), you don't need to rebuild it. You can do a From in your own Dockerfile. You may want to switch user at the end of your Dockerfile. – ctrl-alt-delor Mar 16 at 17:27
  • 1
    Good question. I searched for "Kong API Gateway Docker container" -- from your question, and selected the docker hub record ( hub.docker.com/_/kong ). I then clicked the version that you said, I found everything there. I also knew that there is always an ently-point, usually a shell script. – ctrl-alt-delor Mar 16 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.