Last active
March 4, 2021 01:50
-
-
Save roshane/130e91acd525bfc9960938c6dd44a33e to your computer and use it in GitHub Desktop.
login to docker container as root user #containerlogin #docker #root #container #root login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usageMessage="Usage: $> docker-container-in.sh {container name}" | |
if [[ -z $1 ]] | |
then | |
echo $usageMessage | |
exit 1 | |
fi | |
#get running container id | |
containerId=$(docker ps | grep $1 | cut -d' ' -f1) | |
echo "container id [$containerId] found for running container named [$1]" | |
echo "logging into [$1 $containerId] as root user" | |
docker exec -u0 -it $containerId bash | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment