Skip to content

Latest commit

 

History

History
76 lines (63 loc) · 2.54 KB

HowToUse.md

File metadata and controls

76 lines (63 loc) · 2.54 KB

Basic usage

JSON configuration (Adjust this to your needs)

{
    "AllowedHosts": "*",
    "SimpleMqttServer": {
        "Port": 1883,
        "Users": [
            {
                "UserName": "Hans",
                "Password": "Test"
            }
        ],
        "DelayInMilliSeconds": 30000,
        "TlsPort":  8883 
    }
}

Run this project in Docker from the command line (Examples for Powershell, but should work in other shells as well):

  1. Change the directory

    cd ..\src\SimpleMqttServer
  2. Publish the project

    dotnet publish -c Release --output publish/
  3. Build the docker file:

    • dockerhubuser is a placeholder for your docker hub username, if you want to build locally, just name the container simplemqttserver
    • 1.0.2 is an example version tag, use it as you like
    • -f Dockerfile . (Mind the .) is used to specify the dockerfile to use
    docker build --tag dockerhubuser/simplemqttserver:1.0.2 -f Dockerfile .
  4. Push the project to docker hub (If you like)

    • dockerhubuser is a placeholder for your docker hub username, if you want to build locally, just name the container simplemqttserver
    • 1.0.2 is an example version tag, use it as you like
    docker push dockerhubuser/simplemqttserver:1.0.2
  5. Run the container:

    • -d runs the docker container detached (e.g. no logs shown on the console, is needed if run as service)
    • --name="simplemqttserver" gives the container a certain name
    • -p 1883:1883 opens the internal container port 1883 (Default MQTT without TLS) to the external port 1883
    • -p 8883:8883 opens the internal container port 8883 (Default MQTT with TLS) to the external port 8883
    • -v "/home/config.json:/app/appsettings.json" sets the path to the external configuration file (In the example located under /home/appsettings.json) to the container internally
    docker run -d --name="simplemqttserver" -p 1883:1883 -p 8883:8883 -v "/home/appsettings.json:/app/appsettings.json" --restart=always dockerhubuser/simplemqttserver:1.0.2
  6. Check the status of all containers running (Must be root)

    docker ps -a
  7. Stop a container

    • containerid is the id of the container obtained from the docker ps -a command
    docker stop containerid
  8. Remove a container

    • containerid is the id of the container obtained from the docker ps -a command
    docker rm containerid