Docker Community Forums

Share and learn in the Docker community.

Starting a Docker images and getting into container as root

When start a Docker image and it is running as a container, I am sent in as root. I do not want this. Just being sent it as a user would be fine.

Can I go in a user and if so how do I do it?

Respectfully

1 Like
docker exec -itu <user_you'd_like_to_get_in_as> <container_id> bash

I hope this helps :slight_smile:

1 Like

Yes, that works thanks.

Natalia1479

The installation script is available at https://get.docker.com/rootless.

$ curl -fsSL https://get.docker.com/rootless | sh
Make sure to run the script as a non-root user. To install Rootless Docker as the root user, see the Manual installation steps.

The script shows environment variables that are required:

$ curl -fsSL https://get.docker.com/rootless | sh

Docker binaries are installed in /home/testuser/bin

WARN: dockerd is not in your current PATH or pointing to /home/testuser/bin/dockerd

Make sure the following environment variables are set (or add them to ~/.bashrc):

export PATH=/home/testuser/bin:$PATH
export PATH=$PATH:/sbin
export DOCKER_HOST=unix:///run/user/1001/docker.sock

To control docker service run:

systemctl --user (start|stop|restart) docker