Skip to content

A docker container to run a suite of Network Tools on an Alpine Linux image. Based on wbitt/Network-MultiTool.

License

Notifications You must be signed in to change notification settings

ericwastaken/network-multitool

Repository files navigation

NETWORK MULTI-TOOL

Summary

A docker container with a set of tools for Linux. This is based on the Network-MultiTool container, but with a few tweaks added, including support for the Azure CLI, Python3, and a few other tools.

For all the commands packaged in multitool see: https://github.com/ericwastaken/Network-MultiTool-Base.

Available on Docker Hub

This container is available on Docker Hub at https://hub.docker.com/repository/docker/ericwastakenondocker/network-multitool.

Dependencies

  • Docker must be installed on the host system.
  • The host must have internet access to build the initial image. (See "Offline Usage" below if you need to use this in an offline environment.)
  • If you intend to submit to Docker Hub, you must be logged in to Docker Hub.

Usage

CONTAINER START

Start the container with the following command:

$ docker compose up -d
  • Uses an NGINX web server to keep the container running.
  • Network mode is HOST network, so the container will use the host's network stack and commands will have network host visibility.
  • On first "up" the image will build from the Dockerfile. This might take a few minutes. See below for "offline usage" if you need to use this in an offline environment.

CONTAINER SHELL

After the container is running, get a shell with:

$ docker exec -it network-multitool /bin/bash
  • You can also use the convenience script:
      $ ./x-shell.sh
  • Note the host directory ./host-volume is mapped into the container into /root/host-volume. This is a
  • convenient way to move files between the host and the container.
  • Exit the shell with CTRL-D or the exit command.

CONTAINER EXEC

With the container running, run any command with:

$ docker compose exec -i network-multitool <your-command> <args>'
  • You can also use the convenience script x-exec.sh your-command and any args.

For example, to get the public IP of the host (using a CURL against https://ifconfig.co):

$ docker compose exec -i network-multitool curl https://ifconfig.co

or

$ ./x-exec.sh curl https://ifconfig.co

BIN MAPPING TO YOUR PATH (CONTAINER EXEC WITH PATH ON HOST)

This project provides a bin-mapping folder with a command that can be used to run commands inside the container. It's possible to add this folder to your PATH so that the tools could be used inside the HOST by replacing the tool name with nmt <tool-name>.

In your .basrc or .zshrc file add the following line to add the container's bin mapping to your path:

export PATH="/path/to/this/repo/bin-mapping:$PATH"

For example, with the above in place, you can run the following commands from the host:

# curl a remote site
$ nmt curl https://ifconfig.co
# netcat a host for a port
$ nmt nc -zv google.com 443
# Pass stdin to the container's jq command
$ cat /some/file/with/json | nmt jq
$ some-command-that-produces-json | nmt jq

(Note, these are only a few examples. ALL the commands in the container are available this way.)

CONTAINER STOP

To stop the container, use:

$ docker compose down

Offline Usage

If you need to use this container on a server that does not have Internet, you can:

  • Add any Python packages you need to host-volume/python-packages.txt. See "Python Support" below.
  • Build the image on a connected server first. From the root director of this repo:
    $ docker compose build
    • You can also use the convenience script x-build.sh.
  • Export the docker image to a file. From the root directory of this repo:
    $ ./x-export.sh
  • Move the all the files in this repo, including the exported docker image, using any offline method (usb drive, etc.)
  • The exported image is placed in the ./exported directory if you use the convenience x-export.sh script.
  • Load the image on the offline server. On the offline server, from the root directory of this project:
    $ ./x-import.sh
  • Start the container on the offline server as described above.

Python Support

The container is enhanced with Python3, Pip3 and any packages defined in host-volume/python-packages.txt. This is useful for running python scripts in the container.

Scripts can be run from the host or from inside the container.

The pylogix package is installed by default along with some example scripts demonstrating how to communicate with Allen-Bradley PLCs.

Notes:

  1. The pylogix package is not installed on the host. It is only installed in the container.
  2. This project is not affiliated with Allen-Bradley or Rockwell Automation. The pylogix package is open source and available at: https://github.com/dmroeder/pylogix.

Running Python Scripts from the Host

With the container running, run your script with:

$ docker compose exec -i network-multitool python <your-path>/<your-script>.py <args>
  • You can also use the convenience script x-exec.sh your-python-script.py and any args.
  • Or if you've mapped the bin-mapping folder into your path, you can run:
    $ nmt python <your-path>/<your-script>.py <args>

Running Python Scripts from the Container

Once the container is running, enter the container. (See "CONTAINER SHELL" above.) Run your script with:

$ python <your-path>/<your-script>.py <args>'

Adding Python Packages

Simply edit the file host-volume/python-packages.txt and add the package name and version to the file. The package will be installed the next time the container image is built. You might need to rebuild with docker compose build or with the convenience script ./x-build.sh.

Azure CLI

The image includes the Microsoft Azure CLI preinstalled and available on the PATH as az.

  • Check version:
    $ ./x-exec.sh az version
  • Authenticate (interactive on a machine with a browser):
    $ ./x-exec.sh az login
  • Use it as you would on a host with Azure CLI:
    $ ./x-exec.sh az account show
    $ ./x-exec.sh az group list

Notes:

  • The CLI is installed in an isolated virtual environment at /opt/az and symlinked to /usr/local/bin/az.
  • No additional setup is required; az is ready to use when the container is running.

Publishing to Docker Hub

This repo includes convenience scripts to build and publish the image to Docker Hub.

Prerequisites:

  • Docker is installed and you are logged in to Docker Hub:
    $ docker login
  • Set your image name and tag in docker-build-manifest.env:
    • NAME should be your Docker Hub repo name, e.g. yourname/network-multitool
    • CURR_TAG is the version tag you want to publish, e.g. 20250816
    • BUILDER_NAME is the buildx builder name (used for multiplatform builds)

Steps:

  1. Build the image locally (choose current platform or multi-platform):

    $ ./x-build.sh
    • Option 1 builds with buildx for linux/amd64 and linux/arm64.
    • Option 2 builds only for your current platform.
  2. Push to Docker Hub:

    $ ./x-deploy-dockerhub.sh
    • Option 1 uses docker buildx build --platform linux/amd64,linux/arm64 --push to build and push.
    • Option 2 tags and pushes your locally built image for the current platform.
    • The script tags the image as both $NAME:$CURR_TAG and $NAME:latest and pushes both tags.

Customizations

This section discusses the customizations this repo makes to the original Network-MultiTool container.

  1. Convenience scripts, which verify dependencies and run docker commands when necessary:
    • x-build.sh - Builds the docker image.
    • x-deploy-dockerhub.sh - Builds and pushes the docker image to Docker Hub.
    • x-up.sh - Starts the container.
    • x-force-build-and-up.sh - Forces a rebuild of the docker image and starts the container.
    • x-exec.sh - Runs a command inside the running container.
    • x-shell.sh - Starts a shell in the container.
    • x-export.sh - Exports the docker image to a file. Useful for moving the image to an offline server.
    • x-import.sh - Imports the docker image from a file. Useful for loading the image on an offline server.
  2. Support for running the container commands via the host's PATH.
  3. Aliases inside the container:
    • ll (long list) mapped to ls -al
  4. Maps the host directory host-volume into the container's /root/host-volume directory.
  5. Support for python3, pip3 and any python dependencies listed in host-volume/python-packages.txt. Some example
  6. python scripts are also included.

About

A docker container to run a suite of Network Tools on an Alpine Linux image. Based on wbitt/Network-MultiTool.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors