Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run official Tensorflow Docker Image as a non root user?

I currently run the official Tensorflow Docker Container (GPU) with Nvidia-Docker:

  • https://hub.docker.com/r/tensorflow/tensorflow/
  • https://gcr.io/tensorflow/tensorflow/

However, I can't find a way to set a default user for the container. The default user for this container is "root", which is dangerous in term of security and problematic because it gives root access to the shared folders.

Let's say my host machine run with the user "CNNareCute", is there any way to launch my containers with the same user ?

like image 493
Jonathan DEKHTIAR Avatar asked Nov 01 '25 20:11

Jonathan DEKHTIAR


1 Answers

Docker containers by default run as root. You can override the user by passing --user <user> to docker run command. Note however this might be problematic in case the container process needs root access inside the container.

The security concern you mention is handled in docker using User Namespaces. Usernamespaces basically map users in the container to a different pool of users on the host. Thus you can map the root user inside the container to a normal user on the host and the security concern should be mitigated.

like image 130
yamenk Avatar answered Nov 03 '25 13:11

yamenk