Showing posts with label "bash into container". Show all posts
Showing posts with label "bash into container". Show all posts

Wednesday, 30 June 2021

Bash into a container

Bash into a container


After creating a container in detach mode. If you are looking to bash into a container then you can follow this.

There is a docker exec command that can be used to execute a command on a container that is already running.

Use docker ps to get the name of the existing container


[root@jkcli ~]# docker ps
CONTAINER ID   IMAGE     COMMAND              CREATED          STATUS          PORTS                                   NAMES
cb72f5d90279   httpd     "httpd-foreground"   17 minutes ago   Up 17 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp   jkapache
[root@jkcli ~]#


Use command docker exec -it <container name> /bin/bash to bash into a container

[root@jkcli ~]# docker exec -it cb72f5d90279 /bin/bash
root@cb72f5d90279:/usr/local/apache2#