Lab 11: Practical Applications of Containers

Introduction

In this lab you will perform the following tasks:

  • Setup Zabbix for Service Monitoring using Docker

  • Setup Archivebox using Docker

Preliminaries

  1. Open an SSH remote terminal session to your Linux server’s IP address

    1. Connect to ITCnet from the computer you will be using as your administrative PC. In most cases this means connecting to the ITC Student VPN (unless you are using the Netlab Windows Administrative PC).

    2. Run the PuTTY software on your computer (or the Windows Administrative PC) and enter in the IP address of your Linux server VM in the "Host Name" box and click the "Open" button.

      Remember that if you do not have a Windows computer to connect from you can either figure out how to SSH from your own computer over the VPN to your Linux server or you can use the Windows Administrative PC that is provided for you in Netlab.
  2. Login with your standard user’s username and password

Setup Zabbix for Service Monitoring using Docker

  1. It’s often important to be able to monitor your servers and other IT infrastructure for key parameters and uptime. One tool that allows this is the Zabbix monitoring system. However, it can be complex to get all of the services needed for Zabbix server to function up and running. Docker can be used to handle this sort of setup with ease so we’ll use it as another example of how to use Docker and Docker Compose.

  2. We will mostly be following the Zabbix instructions for running using Docker Compose. If you have any issues with this section of the lab please refer to those instructions.

  3. From your home directory run the git clone https://github.com/zabbix/zabbix-docker.git command which will use the Git program to download the latest pre-made Docker Compose files from the Zabbix Docker Git Repository.

    ben@2480-Z:~$ git clone https://github.com/zabbix/zabbix-docker.git
    Cloning into 'zabbix-docker'...
    remote: Enumerating objects: 103795, done.
    remote: Counting objects: 100% (12690/12690), done.
    remote: Compressing objects: 100% (2235/2235), done.
    remote: Total 103795 (delta 10703), reused 12296 (delta 10394), pack-reused 91105 (from 1)
    Receiving objects: 100% (103795/103795), 34.61 MiB | 11.10 MiB/s, done.
    Resolving deltas: 100% (80009/80009), done.
    ben@2480-Z:~$
  4. You should see a new zabbix-docker directory has been created in your home directory. Change your working directory to zabbix-docker.

  5. Run the git checkout 7.0 command to make sure you have selected the most recent Docker Compose files for Zabbix 7.0.

  6. You will see in the directory that there are many different versions of Docker Compose files depending on the underlyiung Linux you want to use and the database server you want to use. These are detailed a bit more in the Zabbix documentation for running using Docker Compose. For our purposes we’ll be using the Alpine Linux version with a PostgreSQL database server.

  7. You should see that there is an env_vars subdirectory and a .env file in the zabbix-docker directory. If you take a look inside both of these you’ll see a lot of environment variables that will be used to setup and configure aspects of Zabbix and associated services. There are also a large number of default passwords being set through these variables. For our lab demonstration purposes it’s fine to stick with these defaults but in real-world usage we would want to be sure to better secure the Zabbix infrastructure by changing these defaults!

  8. One thing we do want to change is the default port the Zabbix web server container runs on as we’re already using port 80 for our existing Nginx web server. Open the .env file in a text editor and change the lines ZABBIX_WEB_NGINX_HTTP_PORT=80 to ZABBIX_WEB_NGINX_HTTP_PORT=8080 and ZABBIX_WEB_NGINX_HTTPS_PORT=443 to ZABBIX_WEB_NGINX_HTTPS_PORT=4443 before saving and closing the file.

  9. Unlike in our previous lab we want to carefully select from the many Docker Compose YAML files so we’ll start docker compose with the -f <composeYAMLfile> option using docker compose -f ./docker-compose_v3_alpine_pgsql_latest.yaml up as administrator.

  10. After a few moments the containers should all be created and the database setup.

  11. Try opening a web browser on your administrative PC and browsing to http://z.itc2480.campus.ihitc.net:8080/ (where you have replaced Z with your own Pod ID letter). You should see a Zabbix login prompt, try logging in with the default username Admin and password zabbix (these are case sensititve.)

    Logging in to Zabbix web interface
  12. If you were able to log in successfully you should see a dashboard:

    Zabbix dashboard
  13. You’ll notice that Docker is still running in the foreground on your SSH terminal. Press CTRL-C on your SSH terminal to stop the containers and return to a command prompt.

  14. Run docker compose -f ./docker-compose_v3_alpine_pgsql_latest.yaml up -d this time (notice what’s different from the last time we started the containers).

  15. The containers should now be running in detatched mode so you’ll be returned to the command line but still be able to use the Zabbix web service.

Configure Zabbix Basics

  1. Log in to the Zabbix Web interface from your Administrative PC if you aren’t already there.

  2. Go to the Administration → General → GUI menu and fix the default time zone to be "(UTC-5:00) America/Chicago" Save the change.

  3. Go back to the dashboard and hover over the "Geomap" square. Click the gear icon in the upper right corner. Change the "Initial view" to be "44.828258661346695, -93.05595185117264,15" which are the coordinates of the Technology and Business Center on the Inver Hills campus shown at zoom level 15. Click the "Apply" button to save your changes and the map should update.

  4. Because Zabbix is running inside a Docker container it doesn’t really have visability to your underlying Linux server. Let’s get some initial visability by installing and configuring an agent on the server.

    1. Install the zabbix-agent2 package on your Linux server

    2. Edit the /etc/zabbix/zabbix_agent2.conf file and change the Server=127.0.0.1 line to Server=127.0.0.1,0.0.0.0/0

      This is not a good security setup for production use! To simplify lab setup we are allowing any Zabbix server to connect to our Linux server. You would normally want to restrict Zabbix Agents to listen only from the IP address of your Zabbix server.
    3. Run the systemctl restart zabbix-agent2 command as an administrator to apply the changes.

    4. In the Zabbix Server web interface go to Monitoring → Hosts

    5. Click on the name of the "Zabbix server" and choose Configuration → Host from the pop-up menu:

      Zabbix host popup menu
    6. Change the "Agent IP Address" to be the outside IP address of your Linux server (172.17.50.xx):

      Zabbix host IP change
    7. Click the "Update" button

    8. After a few minutes the "ZBX" icon in the "Availability" column should turn green.

    9. Click on the "Zabbix server" host name again and choose "Latest Data" from the pop-up menu.

    10. Ensure data values have started filling in and there are some recent "Last check" times

  5. Explore some of the data values, dashboards, and graphs available about your Linux server

  6. There is much more configuration that can be done in Zabbix including monitoring services you’re running like HTTP, SSH, DNS, etc. that is beyond the scope of this course.

Setup Archivebox using Docker

  1. There are many useful small tool applications that can be run using Docker. One example of this is ArchiveBox which allows web pages to be captured and archvied for future use.

  2. Begin by creating the ~/archivebox and ~/archivebox/data directories

  3. Change your working directory to ~/archivebox

  4. Download the latest docker-compose.yml file for ArchiveBox by running the command curl -fsSL 'https://docker-compose.archivebox.io' > docker-compose.yml

  5. ArchiveBox has an easy setup process which you can start using the docker compose run archivebox init --setup command as administrator

    1. Set a username when prompted (or press enter to use "archivebox" as a default)

    2. Enter an email address when prompted

    3. Enter and confirm a password when prompted (if the password contains less than 8 characters you will be prompted to bypass a secuirty warning)

  6. Once the setup process is complete open the docker-compose.yml file for editing

    1. Find the novnc: container section of the file

    2. Edit the - 127.0.0.1:8080:8080 line to be - 127.0.0.1:8081:8080 so that the novnc server will use port 8081 instead of 8080 because we’re already using 8080 for Zabbix.

    3. Save and close the file

  7. Now run docker compose up as an administrator to start the server containers

  8. Try accessing http://z.itc2480.campus.ihitc.net:8000 (replacing z with the Pod ID letter of your own pod) from the browser of your Administrative PC

  9. Assuming that access is successful press CTRL-C in your SSH session to stop the containers.

  10. Remove the old containers with the docker compose down command as an administrator

  11. Run docker compose up -d as an administrator to start the server containers in detatched mode

  12. After waiting a few moments the web interface should be up and running again

  13. Log in using the link in the upper right corner and the username/password you setup

  14. Find a few URLs of web pages online and try adding them to ArchiveBox to see how it can archive the page contents.

Wrapping Up

  1. Close the SSH session

    1. Type exit to close the connection while leaving your Linux server VM running.

  2. If you are using the Administrative PC in Netlab instead of your own computer as the administrative computer you should also shut down that system in the usual way each time you are done with the Netlab system and then end your Netlab Reservation. You should do these steps each time you finish using the adminsitrative PC in future labs as well.

You can keep your Linux Server running, you do not need to shut it down.

Document Build Time: 2024-10-30 23:55:42 UTC
Page Version: 2024.08
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License