Notes
Container logs are deleted when the container is removed. Containers can be referenced by Id (Partial) or Name (Full)
Docker Auto Start
Containers
In the run.sh script include the following command to ensure that the containers restart automatically if the server ever reboots.
restart unless-stopped
Docker Daemon
Centos and RHEL sometimes will not automatically start the docker daemon once installed, to do this enter the following commands to ensure that the docker daemon will start automatically if the server ever reboots.
systemctl start docker
systemctl enable docker
Control Container
Shell
docker <Action> <Container Id>
Actions
- stop - Stops a running container
- start - Starts a stopped container
- restart - Restarts a running container
- rm - Removes a stopped container.
- logs - Show logs of a container where applicable
- ps - Show list of containers.
- exec - Execute a command against a container
- stats - Show statistics related to the host or containers.
List Containers
Show Running Containers
docker ps
Show All Containers
docker ps - a
Logs
All logs for the Virtru Gateway are written to the stdout and are thus saved to the docker host via standard logging in the default location of /var/lib/docker/containers/<container
id>/<container id>-json.log
All logs can be redirected using standard docker utilities. Please reference Docker Log Managment and Configuration
From the cks directory /var/virtru/cks
View Logs
docker logs
View Logs Last 50 Entries
docker logs --tail 50
Search logs for keyword
docker logs | grep <keyword>
Follow Logs
docker logs -f
Follow Logs Starting from 30 minutes ago
docker logs -f --since 30m
Follow Logs Starting from Last 50 Entries
docker logs -f --tail 50
Options
- --tail # - Last # of entries
- -f - Follow the logs - Ctrl + C to exit
- --since - Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
- --until - Show logs through timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
- --details - Show extra details provided to logs
Enter Container
Entering the container should be done with caution as all commands are immediate and can adversely affect the functionality.
Command Structure
docker exec -it <Container Id> <Command>
Enter Bash in Container
docker exec -it <Container Id> /bin/bash
Monitor Container Utilization
This will show the utilization of each container on the host.
Statistics
docker stats
Container Statistics
docker stats <Container Id>