I am late to the party, but this answer might help someone that uses Ubuntu inside a Docker container.
I recently created a Docker container based on Ubuntu 16.04.1.
By default, the Docker Ubuntu image is a stripped down version of Ubuntu, which does not have a vast majority of common tools including sudo
.
Besides, by default, the user is logged in to the Docker container as root.
Therefore, I started the container with the docker run
command, and installed the 'sudo' package:
root@default:/# apt-get install sudo
Running the command adduser myuser sudo
reported error adduser: The user 'myuser' does not exist.
.
After reading this answer, I first ran the command to create the user:
root@default:/# adduser myuser
Then ran the following command:
root@default:/# adduser myuser sudo
Adding user `myuser' to group `sudo' ...
Adding user myuser to group sudo
Done.
The user myuser was successfully added to the sudo group.