Return to
Portfolio

16. Docker

16.1. Installing

  1. Download the appropriate NXLog install archive from the NXLog website.

    1. Log in to your account, then click My account at the top of the page.

    2. Under the Downloads  NXLog Enterprise Edition files tab, choose the nxlog-4.6.4661_docker.tar.gz archive (which is based on CentOS 7).

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

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

    $ tar -xzf nxlog-4.6.4661_docker.tar.gz
    Table 22. Files in the Docker Archive
    Package Description

    Dockerfile

    The main NXLog Docker definition file

    README.md

    Readme for building NXLog Docker image

    nxlog-4.6.4661_rhel7_x86_64.tar.bz2

    The NXLog RHEL7 package

  4. Configure NXLog. Custom configuration files can be placed in the build directory of the NXLog Docker version, before the build. Every file ending with .conf will be copied into the Docker image and placed in the /opt/nxlog/etc directory.

    Note
    If there is already a configuration file inside the /opt/nxlog/etc directory, it will be overwritten with the custom one.
  5. Build the NXLog Docker image.

    • The standalone version of NXLog Docker image can be built with this command.

      $ docker build -t nxlog .
    • It is also possible to specify the IP address of an NXLog Manager instance at build time. In this case, NXLog will connect automatically at startup. Before build, the CA certificate file, exported from NXLog Manager in PEM format and named agent-ca.pem, must be placed in the Docker build directory.

      $ docker build -t nxlog --build-arg NXLOG_MANAGER=<NXLOG-MANAGER-IP> .
  6. Run the container using the docker command.

    $ docker run -p <HostPort>:<ContainerPort> -d nxlog
  7. Check that the NXLog container is running with the docker command.

    $ 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
    [...]

16.2. Upgrading

The upgrade process consists of creating a new NXLog Docker image build and running a new container instance with the newly built image.

  1. Follow steps 1-5 above to build a new Docker image.

  2. Get the container ID of the running NXLog instance and stop the running container.

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

    $ docker run -p <HostPort>:<ContainerPort> -d nxlog
  4. Check that the new NXLog 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. Any old containers and images that are no longer needed can be removed with docker rm -v <containerID> and docker rmi <imageID>, respectively. See Uninstalling below for more information.

16.3. Uninstalling

The uninstallation process of the NXLog Docker version is simply removing the running container and the image.

  1. Get the container ID of the running NXLog instance and stop the running container.

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

    $ docker rm -v <containerID>
  3. Any other remaining containers that are not running can be listed with docker ps -a, and removed.

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

    $ docker images
    $ docker rmi <containerID>