Exec into a Container as Root without Sudo or a Password

preview_player
Показать описание
This is handy when your Dockerfile sets a non-root user and you need to quickly debug something.

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:18 -- When you might want to do this
0:56 -- Connecting as a non-root user with Docker Compose
1:47 -- Connecting as the root user with the --user flag
2:23 -- Connecting as both users at once
3:51 -- Technically you can use id 0 instead of referencing root too
4:32 -- My projects come with a shortcut to get into a bash prompt
4:47 -- Exec'ing in as the root user works with regular Docker too
Рекомендации по теме
Комментарии
Автор

Hi Nick

I want to do opposite.
I want to stop everybody from using docker exec to enter as root for security reasons.
Even docker exec is used then it should ask for password even for root user.
Can you please tell how to do it?

abhinavkumar
Автор

I want to code from within a docker container as a non-root user. I want to bind a folder from the host machine and also make them writable from the outside. Basically having a containerized dev environment with no need for snapshots/copying. Do you have an article/video on that?

mentalmarvin