I'm running Ubuntu xenia in my docker container (this is a container running in my OS X VM Host). When you run the docker run command that created my container, it logs you in as root.
So when I try to install Linuxbrew after all this and after installing curl and ruby in my container via app-gret, I get the error don't run this as root!
when I try to then install Linuxbrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)"
I want to be able to sill run this somehow. If docker run logs me in as root, what are my options here to get around this limitation on root so I can still run this command? If docker always logs me in as root to a container, what do people usually do in the situations where they want to install stuff like this as a non-root user on a container with Ubuntu?
Note: I'm new to both Ubuntu, Linux, and docker. So that implies I may not be aware of all basics and there is a lot to know.
A Google search lead me to this. I personally don't think it's a nice and clean solution, but it should be able to do the job. What this solution does is the following:
Instead of directly starting the program in the container, there is a two-step launch going on: First, a small script is launched with docker, which basically creates a new user in the container, and then executes the main program as this new user. This is the script that is used there, /home/r/script.sh
being the program that is to be started:
#!/bin/bash
adduser --disabled-password --gecos '' r
adduser r sudo
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
su -m r -c /home/r/script.sh
If you want a shell as that user, you might be able to put bash there instead.
No comments:
Post a Comment