Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the default user for docker exec?

Tags:

Is root the default user when calling docker exec (without --user)?

Does a USER line in the Dockerfile affect the default user for docker exec?

like image 610
Beau Barker Avatar asked Aug 29 '18 05:08

Beau Barker


1 Answers

The default user in docker exec is the same user used to start the container which can be set in docker run or your compose file.

If you do not explicitly set the user when starting the container, it will default to the user configured in the image, you can inspect the image to look this up. This is configured by the last USER line in the Dockerfile. It may also be configured by a parent image specified by the FROM line.

If neither the image, nor the run command specifies a user, docker defaults to root, uid 0.

like image 143
BMitch Avatar answered Sep 19 '22 04:09

BMitch