These are some of the shortcuts for inspecting running containers.

First, of course, get the ID of the running container

docker container ls -a (show me all the running containers on this host).

 

docker exec -i -t 1aa86f5bf93a | PS
docker run -it <image-name> powershell docker r

To connect to docker and launch a PS prompt inside the container

docker exec CONTAINERID

To Inspect a folder or a file inside the container

docker exec containeriD | ls <dir path>

To List all the processes inside the container

First connect to it using docker exec and launch a PS prompt

 docker exec <container> | PS

Then, just use Powershell’s

        List-processes

 

To view the event log inside the container (once you have a PS prompt using     docker exec <container> | PS  )

get-eventlog system -newest 10000 | format-table -wrap > c:\data\syslog.txt (if c:\data is defined as a volume, it can be read from the host)

# this shows source as ‘Docker’ but can change you ‘Application’ or custom

Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-5) | Sort-Object Time

#To search for specific terms in an event log

Get-WinEvent –listlog *mykeyword*

To Copy files from host to container

 docker cp foo.txt mycontainer:/foo.txthttp:

To Inspect all the properties (volumes, ports…) of a running container

First get the ip address of the running container – lookup the container id (docker container ls)

docker inspect c5e8de7faf05 - will give you the IP

 

docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID

To Automate hitting a container URL

curl -i "https://$(docker-machine ip node-1) (If no curl, use powershell as shown below)
Invoke-WebRequest -Uri https://$(docker-machine ip node-1)  | Select-Object -ExpandProperty Content
Invoke-WebRequest http://localhost -method GET

To push/pull docker images from an external registry (e.g. Azure Container Registry)

$env:docker_registry = “myregistry.azurecr.io

docker login -u myregistry –p password myregistry.azurecr.io

docker-compose push/pull

Summary

I have been fortunate to work as a docker architect for a few oil and gas companies in Houston, TX – as well as state agencies in Austin, TX. These are just some commands I found helpful while working with and testing containers – in my role as a docker architect. docker exec should be your go to command for getting access to a running container. Once in, you can run powershell just like you would on a windows host. Of course, if you are on linux, you would use bash or some other scripting platform.

Thoughts? Comments?

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.