Purpose

This document will list steps for customers to enable log-rotations for their existing docker containers that are not using log-rotations.

If you are running Tulip's on-premise connector host in a docker container, and already have log-rotations enabled for docker on the VM, you can ignore this article or if you need more information on installing Tulip's on-premise connector host, please refer to this article.

What is log-rotations in Docker?

Tulip's on-premise connector host runs in a docker container that uses a json-logging driver for storing log files locally on the VM. These files can use a substantial amount of disk-space if log-rotations for docker is not enabled. Log-rotation allows restricting the size of a log file & the number of such files for each container.

Implementation

The following steps will highlight how to enable log-rotations for docker, restart docker, delete the existing container & create a new container for Tulip's on-premise connector host.

This procedure will cause a small amount of downtime on the connector host, so it's advised to run the following commands during scheduled downtime, or when the connector host is not in use.

Log-Rotations

Log rotations can be enabled by running the following commands on a Linux VM

$ sudo su
$ touch /etc/docker/daemon.json
$ cat > /etc/docker/daemon.json <<EOF
> {
> "live-restore": true,
> "log-driver": "json-file",
> "log-opts": {
> "max-size": "10m",
> "max-file": "3"
> }
> }
> EOF

Restarting Docker

In order for docker to use the log-rotations configuration, please restart docker by running the following command

$ sudo systemctl restart docker

Deleting existing container

$ sudo docker ps #This will list the details of the existing container, you can copy the container id which will be used in the next step
$ sudo docker stop <container id>
$ sudo docker rm <container id>

Creating a new container

Re-run the following docker run command which was executed the first time Tulip's on-premise connector host was setup

$ docker run -d \
--name tulip-connector-host \
-e TULIP_FACTORY='https://<FACTORY>.tulip.co' \
-e TULIP_UUID='<UUID>' \
-e TULIP_MACHINE_SECRET='<SECRET>' \
-e TULIP_DEVICE_TYPE=onprem
-e HTTP_PROXY='' \
-e HTTPS_PROXY='' \
-e EXIT_ON_DISCONNECT=true \
--restart=unless-stopped \
--net=host \
--mount type=volume,source=tuliplog,target=/log \
bckca2dh98.execute-api.us-east-1.amazonaws.com/public/connector-host:prod

If the above credentials are not available, please reach out to Tulip.

The container running Tulip's on-premise Connector Host should be set up now along with log-rotations enabled.

To confirm, if the container is back up, you can check the logs of the new container by running the following command

$ docker logs <name of the container>

Did this answer your question?