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 command 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 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
Remove Postfix
Centos has postfix built in to the base image which will sometimes conflict with the Virtru docker containers. Remove postfix with the following commands before spinning up the gateway images.
systemctl stop postfix
systemctl disable postfix
yum remove postfix
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
View Logs
docker logs <Container Id>
View Logs Last 50 Entries
docker logs <Container Id> --tail 50
Search logs for keyword
docker logs <Container Id> | grep <keyword>
Follow Logs
docker logs <Container Id> -f
Follow Logs Starting from 30 minutes ago
docker logs <Container Id> -f --since 30m
Follow Logs Starting from Last 50 Entries
docker logs <Container Id> -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>
Check Mail Queue
docker exec -it <Container Id> mailq
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>