A
A
Alexander Nazarov2017-09-29 04:33:57
linux
Alexander Nazarov, 2017-09-29 04:33:57

How to run containers as different users in Docker?

Is it possible to run Docker containers as other users than just the user who installed Docker.
After adding a new user to the Docker group, I
sudo usermod -aG docker qwerty
tried running the container on its behalf:
docker run --name test --user qwerty
I got an error:

docker: Error response from daemon: linux spec user: unable to find user qwerty: no matching entries in passwd file.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AUser0, 2019-06-18
@Elbakidze

The usual solution:
Bad practice:

if (!in_array(trim(@$_GET['lang']), $config['langs'])) {

I
Immortal_pony, 2019-06-18
@Immortal_pony

Use default value if 'lang' is not passed in GET string

(!in_array(trim($_GET['lang'] ?? null), $config['langs'])) {

A
A1estro, 2017-09-29
@wergio

--user - пользователь внутри контейнера.
Чтобы запускать контейнер от пользователя qwerty, надо либо sudo -u qwerty docker run, либо su qwerty, и потом запускать контейнер.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question