Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, June 14, 2020

Root password of a Docker container

Root User Privileges in a Docker Container


Often we will come across situations where the default user setting in docker container will be not be sufficient to perform operations. 

Lets say to kill a process, inspect or edit some system files, import certificates or even to install some tool..


We have few options to accomplish this..


Easiest of all:

docker exec -u 0 -it <container-name> bash
 
By default, "0" denotes root user. You can also choose to specify, simply as "root". Also its better to specify the working directory as below..

docker exec -u root -it --workdir / <container-name> bash



Other options that are available are during the container image build:

Make necessary file permissions, etc., during the image build in the Docker file

If all the packages are available in your Linux image, chpasswdin the dockerfile before the USER utility

Hope this helps..!!

10 Useful Unix Commands - Must for Debugging


Useful Unix Commands for Debugging with Examples


This is my list of commands, found useful while debugging issues in logs, servers process, etc., With regard to the list, will share the commands which I use in the real world scenarios..

  • lsof - Used to get the list of "open files" in linux and all the processes that opened them. I find them useful to search / find the processes that are listening on a given Port.          
            lsof -i tcp:8443

This will give the Process ID, service name which listens on the port (8443) and much more.. Particularly useful to debug different services running on the same server. 

Root password of a Docker container

Root User Privileges in a Docker Container Often we will come across situations where the default user setting in docker container will be n...