Skip to main content

Posts

Showing posts with the label Docker

How to login to a running Docker container as root?

How to login to a running Docker container as root? ------------------------------------------- ---- TL DR: docker exec -it --user root <container> bash ------------------------------------------- ---- Most of the times the application would run in a different user. as specified in the docker file. Such a docker file is mentioned below. FROM openjdk:17-alpine RUN apk update && apk add --no-cache gcompat && apk add curl bash RUN addgroup -S appuser && adduser -S appuser -G appuser USER appuser:appuser # some custom code to run an app In this Dockerfile the line " USER appuser:appuser" specifies the user and group which the application should run. Also, any commands following this line will run as the same user, and if you login the container without specifying the user explicitly, it will be the default user. eg: Docker exec accepts another parameter to specify the user. With that we can login as root or any user we want. 

Install Docker on Windows 11 with WSL Ubuntu 22.04

This is to install Docker within Ubuntu WSL without using the Windows Docker application. Follow the below steps. Install Ubuntu 22.04 WSL 1. Enable Windows Subsystem for Linux and Virtual Machine platform Go to Control Panel -> Programs -> Programs and Features -> Turn Windows features on or off 2. Switch to WSL 2 Open Powershell and type in the below command. wsl --set-default-version 2 If you don't have WSL 2, download the latest WSL 2 package and install it.  3. Install Ubuntu Open Microsoft Store and search for Ubuntu. Select the version you intend to install. I'd use the latest LTS version Ubuntu 22.04. Click on the Get button. It will take a couple of minutes to download and install. 4. Open up the installed Ubuntu version that was installed. If you get an error like the below image, make sure to install the WSL2 Kernel update .  If it's an older Ubuntu version the error message would be something like the image below. Error: WSL 2 requires an update to its ...