Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Get shell in running Docker container

The post Get shell in Running Docker Container appeared first on ma.ttias.be.

This has saved me more times than I can count, having the ability to debug a running Container the way you would in a "normal" VM.

First, see which containers are running;

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  [...] NAMES
925cc10d55df        66cc85c3f275        "gitlab-runner-ser..."   [...] runner-f500bed1-project-3888560-concurrent-0-mysql-0-wait-for-service
0ab431ea0bcf        3e3878acd190        "docker-entrypoint..."   [...] runner-f500bed1-project-3888560-concurrent-0-mysql-0
4d9de6c0fba1        nginx:alpine        "nginx -g 'daemon ..."   [...] nginx-container

To get a shell (Bash) on a container of choice, run this;

$ docker exec -i -t nginx-container /bin/bash

The -t nginx-container determines which container you want to enter, it's the name in the last column of the docker ps output.

Alternatively, use the container ID;

$ docker exec -i -t 4d9de6c0fba1 /bin/bash

Don't use docker attach, as that'll give you funky results if the initial command that's started in a Docker container is something like MongoDB or Redis, the instance will be killed.

The post Get shell in running Docker container appeared first on ma.ttias.be.



This post first appeared on Ma.ttias.be ~ The Web, Open Source, PHP, Security,, please read the originial post: here

Share the post

Get shell in running Docker container

×

Subscribe to Ma.ttias.be ~ The Web, Open Source, Php, Security,

Get updates delivered right to your inbox!

Thank you for your subscription

×