Running Docker Containers as a Non-root User with a Custom UID / GID

preview_player
Показать описание
For volumes it's important that your UID / GID on your Docker host matches what's in the container.

Hit the subscribe button to receive more videos like this!

REFERENCE LINKS
---------------------------------------------------

COURSES
---------------------------------------------------
Courses I've created that focus on web dev and deployment topics.

THE TOOLS I USE / GEAR
---------------------------------------------------

FOLLOW ME ELSEWHERE
---------------------------------------------------

TIMESTAMPS
---------------------------------------------------
0:00 -- Intro
0:07 -- Why is this important when using Docker volumes?
1:19 -- Starting the project to see what we're working with
2:13 -- What if your uid/gid isn't 1000? Demo'ing the problem
5:00 -- Setting build args for UID / GID and assigning them to a group and user
10:33 -- Checking out the new env vars in the .env file
12:29 -- Changing the UID and GID env vars for our other user to fix the issue
14:55 -- Updating a file to make sure volumes are working
15:26 -- How would you have solved this problem?
Рекомендации по теме
Комментарии
Автор

This has been a time-saver for me! I bought a course on Udemy that goes through docker, but totally spend like 2 sentences on this. I've been working with AI and config files for about a week now and finally got my app configured, but now I'm hitting this permission thing. I've been googling for about an hour and just now came across your video! THANK YOU! I just bought YOUR course. Please include this as a separate detailed section in your course!

RadTechDad
Автор

Hi Nick. Thanks for the video. There is no better way to do this as far as I know. I've seen this approach in many projects.

nnutipa
Автор

Hi Nick. Really like your content. However, you really need to talk slower. It would greatly help in following along with the video. Thanks

bmontegani
Автор

about same amount of people suffered from the issue and went to/came after viewing the official video from VScode

forgottenvy
Автор

Great video Nick!!! Seems like this is the way to go if you are building your own images. Was wondering what you would do if you work with pre-built images that you pull from a registry.
How you run these safely? I think you would need to use: docker user namespace remapping correct?

alphenit
Автор

Is it possible to configure docker on my pc to always use a non-root user? So I don't have to set it everytime for every project I have?

arsshady
Автор

Hey Nick! What is your opinion about having a sftp container that shares a volume with an nginx container in order to update files remotely? I am confused about nginx needing its user www-data rw access and the custom sftp user being blocked because of permissions. Which approach would you take in this situation?

TheRcfrias
Автор

Hey Nick thanks for the video. May I ask you to explain how to define, set, and change the UID for Image User?

vahidrahimi
Автор

How about using docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) .... then you don't have to hard code the value in the .env file.

tonyc
Автор

I Nick, I need your help for setting up of OpenGrok as a container with UID & GID could you please help me...

ChethanC-nqzk
Автор

permission denied for groupadd. Using docker desktop

NoelSoong-nm