A Docker container is a light weighted software package which can operate independently.

i.e. It has its all required dependencies to run an application works like an independent system.

Sometimes we need to work on the running container to debug and analyze the outputs. We can do it very easily. Let’s do it.

Lets pull a image from DockerHub . Let pull a redis docker image.

 docker pull redis 

We can run this image with below command:

 docker run -d -p 6379:6379 redis 

check the container is up and running by below command . It will show all the containers which are running.

 docker ps 

To see the logs of running container by using below command.

 docker logs container_id 

Let’s run Redis commands on a running container. We can do by entering into the container .

Type command to enter into container by entering the actual container_id . In my case container id is “af5b9c2e3e55”.

 docker exec -it container_id sh 

Then, you will see Linux terminal will appear. You can run all the Linux the commands in that terminal. let’s run redis-cli on that terminal.

 # redis-cli 

You see below console open for accepting next command after redis-cli command.

 127.0.0.1:6379>

you can execute all redis commands on here.

127.0.0.1:6379> keys *
1) "myKEY"
127.0.0.1:6379> TTL "myKEY"
(integer) -1

You can debug like this.

Also you can run below command to open redis client of container.

 docker exec -it conatiner_id redis-cli 

You can explore more about Docker.

Thanks for reading.