RECOMMENDED Amnezia Premium: Works Where Other VPNs Fail

Unblockable AmneziaWG 2.0 & XRay protocols. Perfect for lag-free access to ChatGPT, Claude AI, global freelance marketplaces, and restricted streaming networks with clean RAM-only privacy.

To run a Docker container from a user in Unix/Linux

The container will always run as root, but it so happens that in the Dockerfile prescribed user to work inside of the container. And then when you attempt to use another user, give a password, which I did not know, for example:

$ docker exec-ti jenkins /bin/bash
[email protected]:/$ su -
Password:

As you can see from the above command, I ran Jenkins. The container has a user (Jenkins too), but I don’t know the password. The solution is to use a parameter which will set the desired user at the start of the container:

$ docker exec -it-u your_container_user your_conatainer container_command

Or:

$ docker exec -it --user your_container_user your_conatainer container_command 

Here is an example from Jenkins:

$ docker exec -it-u root jenkins /bin/bash

With this command, I connect to the container as root user.

Yes, but if there is a need to launch the container from another user, you should use:

$ sudo -u your_user "docker run-d --name jenkins --hostname of jenkins.local-p 8080:8080 -p 50000:50000 --restart always-v /usr/local/jenkins/data_2:/var/jenkins_home --dns=10.17.0.3 --dns=10.17.0.4 --dns=1.1.1.1 dns --=74.82.42.42 --add-host=gitlab_local_docker:172.168.0.66 jenkins/jenkins:latest"

Or, first, switch to user and run it from Docker:

$ su YOUR_USER 

And here it is:

docker run-d 
--name jenkins
--hostname of jenkins.local
-p 8080:8080 -p 50000:50000
--restart always
-v /usr/local/jenkins/data_2:/var/jenkins_home
--dns=10.17.0.3
--dns=10.17.0.4
--dns=1.1.1.1
--dns=74.82.42.42
--add-host=gitlab_local_docker:172.168.0.66
jenkins/jenkins:latest

That’s all, “Run a Docker container from a user in Unix/Linux” is completed.

Source: linux-notes.org

🛠️ Top Temporary VPS for Testing & Experiments (2026)

Need a fast cloud server for a few hours or days? Deploy an isolated testing environment, run your scripts, and destroy it without any monthly commitments. Secure payments via Crypto (USDT) & PayPal supported.

AÉZA — Ultimate Testing Environment Flexible rates: from €0.01/hr depending on the billing period (the longer you rent, the cheaper it gets).
Exclusive Welcome Bonus: Get an extra 15% on your first balance top-up within 24 hours after registration.
Deploy on Aeza
Friendhosting — High-Storage VDS Hourly VDS infrastructure (from €0.03/hr) deployed across massive global locations.
• Best-in-class Storage VDS configurations with huge disk space for heavy data testing.
Deploy on Friend
Zomro — Premium Daily Node Daily billing model starting at just €0.16/day (~€0.007/hr) for optimal cost control.
• High-speed hardware platform with a stable presence in the Netherlands (Europe).
Deploy on Zomro
Rork

Linux hobbyist into networking and digital privacy. I use this hub to translate and store technical notes on sysadmin tasks and anonymity tools. Tech should work for people, not the other way around.

Rate author
Add a comment