Docker

This page describes the steps for deploying NXLog Agent as a Docker container application.

Deploying an NXLog Agent container application

Follow these steps to deploy NXLog Agent using Docker:

  1. Log in to the NXLog website.

  2. Click Your account at the top of the page.

  3. Under Downloads, select the product version and Docker as the platform.

  4. Select the archive for your architecture, such as nxlog-6.7.9957-docker.tar.gz for x86-64.

  5. Use SFTP or a similar secure method to transfer the archive to the target server.

  6. Log in to the target server and extract the contents of the archive.

    $ tar -xvf nxlog-6.7.9957-docker.tar.gz
    Table 1. Files in the NXLog Agent Docker archive
    Package Description

    Dockerfile

    The main NXLog Agent Docker definition file.

    README.md

    Readme for building the NXLog Agent Docker image.

    nxlog-6.7.9957_ubuntu22_amd64.tar.bz2

    The NXLog Agent Ubuntu 22 installer file.

  7. Optionally, configure NXLog Agent. You can add custom configuration files to the build directory of the NXLog Agent Docker image. The default NXLog Agent configuration file includes all .conf files found in the build directory, and the build process copies those configuration files into the /opt/nxlog/etc/nxlog.d directory inside the Docker image.

  8. Build the NXLog Agent Docker image.

    • If your NXLog Agent instance is going to connect to NXLog Platform, use the optional NXP_ADDRESS parameter to specify the NXLog Platform Agent Management URL and port. This allows the NXLog Agent to connect automatically at startup.

      The NXP_AGENT_LABEL parameter is also optional, representing a label that identifies the agent. You can use this label when creating auto-enroll rules so that your NXLog Agent instances automatically download and apply preset configurations to start collecting logs immediately.

      To build the image, use the following command replacing the example URL, port and label:

      $ sudo docker build -t nxlog --build-arg NXP_ADDRESS="agents.example.com:5515" --build-arg NXP_AGENT_LABEL="docker-example" .
    • Alternatively, you might want to deploy a standalone NXLog Agent in the Docker image. In this case, you don’t need to specify any parameter. To build the image, use the following command:

      $ docker build -t nxlog .
  9. Run the container with the NXLog Agent Docker image.

    $ docker run -d nxlog
  10. Check that the NXLog Agent container is running.

    $ docker ps | grep nxlog
    a3b4d6240e9d nxlog "/opt/nxlog/bin/nx..." 7 seconds ago Up 6 seconds 0.0.0.0:1514->1514/tcp cranky_perlman
    [...]

Upgrading NXLog Agent

The upgrade process consists of building a new NXLog Agent Docker image and deploying a new container instance from the new image.

  1. Follow steps 1-8 in the deployment instructions above to build a new Docker image.

  2. Retrieve the container ID of the existing NXLog Agent container and stop it.

    $ docker ps | grep nxlog
    $ docker stop <containerID>
  3. Deploy the new container using the docker command.

    $ docker run -d nxlog
  4. Check that the new NXLog Agent container is running.

    $ docker ps | grep nxlog
    a3b4d6240e9d nxlog "/opt/nxlog/bin/nx..." 7 seconds ago Up 6 seconds 0.0.0.0:1514->1514/tcp cranky_perlman
    [...]
  5. You can remove any old containers and images that you’re no longer using with docker rm -v <containerID> and docker rmi <imageID>, respectively. See the uninstall instructions below for more information.

Removing an NXLog Agent container application

Follow these steps to remove an existing NXLog Agent container and image.

  1. Retrieve the container ID of the NXLog Agent container and stop it.

    $ docker ps | grep nxlog
    $ docker stop <containerID>
  2. Remove the container.

    $ docker rm -v <containerID>
  3. List any other stopped containers with docker ps -a and remove them.

    $ docker ps -a | grep nxlog
    $ docker rm -v <containerID>
  4. Finally, list and remove any NXLog Agent Docker images.

    $ docker images
    $ docker rmi <imageID>

Troubleshooting NXLog Agent

Follow these steps to access the NXLog Agent logs while the container is running:

  1. Retrieve the NXLog Agent container ID and run an interactive shell in the container.

    $ docker ps | grep nxlog
    $ docker exec -it <containerID> bash
  2. Change to the NXLog Agent log directory /opt/nxlog/var/log/nxlog.

  3. Read the NXLog Agent log.

    cat nxlog.log