Docker-stacks: how to grant the the sudo properly?

Created on 21 May 2016  路  5Comments  路  Source: jupyter/docker-stacks

I am still getting confused about how to log into the container as user jovyan being able to run sudo, instead of user root.

1

If I run:

docker run -d -p 8888:8888 --user root -e GRANT_SUDO=yes jupyter/datascience-notebook
docker exec -it $(docker ps -aq) /bin/bash

Then I will log into the container with user root, which is not what I want.

2

If I run:

# no --user root
docker run -d -p 8888:8888 -e GRANT_SUDO=yes jupyter/datascience-notebook 
docker exec -it $(docker ps -aq) /bin/bash

I will log into the container as jovyan. Then inside the container if I run something like sudo apt-get update I need to input the password (What's worst that I don't know the password!)

3

If I run:

# add start-notebook.sh and put -e in the end
docker run -d -p 8888:8888 jupyter/datascience-notebook start-notebook.sh -e GRANT_SUDO=yes
docker exec -it $(docker ps -aq) /bin/bash

or

# add start-notebook.sh and put -e in the end
docker run -d -p 8888:8888 --user root jupyter/datascience-notebook start-notebook.sh -e GRANT_SUDO=yes
docker exec -it $(docker ps -aq) /bin/bash

I will get the error after docker exec saying the container is not responding and http://docker:8888 will not be accessible too.

Question

Most helpful comment

I am seriously struggling with this as well. If I use the user as root then I cannot install packages with PIP.

I'd like to be able to run the notebook as the user I want and install additional packages as required without breaking anything else

Does anyone know what the password for the jovyan user is?

All 5 comments

The containers are setup to run the notebook server as jovyan with sudo ability. The minimal-notebook/start-notebook.sh script in the container enables this ability. If you want to run /bin/bash instead of the notebook server, then you have to replicate the logic in that script of adding jovyan to the sudoers file as root and running a bash shell as jovyan thereafter.

I am seriously struggling with this as well. If I use the user as root then I cannot install packages with PIP.

I'd like to be able to run the notebook as the user I want and install additional packages as required without breaking anything else

Does anyone know what the password for the jovyan user is?

@marchofreason The original question here was about running _bash_ in the container instead of the notebook.

If you want to run jupyter notebook in the container, but assign a user id to jovyan other than the default UID=1000, GID=100 combo that the container uses, you can do that and grant sudo access. The README in the stack folder should have the steps as to how.

If you want to completely change the _name_ of the user in the container to something other than jovyan, then you have to build the images from scratch.

I'm closing this issue since it's been inactivate for a few months now. If you have a better idea of how to grant sudo now, please feel free to open PRs against the READMEs so other users can benefit. If you're still struggling, go ahead and reopen the issue with more info.

@parente

As of myself, I found my question answered already. :-) Although I am personally not satisfied with this "design" of Docker.

And I agree that the issue could be closed now. Thank you.

Was this page helpful?
0 / 5 - 0 ratings