Hello @dgomba,
Thanks for sharing more details. I’d like to share some background with you:
When you change a file or setting on the running service container on a balena device, the data you change will not persist over restarts. The service container does not write back the changed files to an image, this is by design and not possible. Thus, on a restart the image is loaded again and the modified files are not modified anymore.
Side note: If you need persistent data in a service please check this documentation Communicate outside the container - Balena Documentation
In your case, you want to create a service image that already contains the necessary information to run a mosquitto mqtt broker that allows anonymous connections.
This setting needs to run from a clone of the repository, which either:
- changes only the docker-compose file
- or changes the docker-compose file and defines a custom Dockerfile
The most simplest solution would follow these three steps
Step 1:
git clone git@github.com:mpous/ming.git
Step 2.
Overwrite the command property in the docker-compose file located in somepath/ming
As you can check here from the eclipse-mosquitto Dockerfile there is already a no-auth configuration file existing in the docker image.
In eclipse run CMD line is defined that mosquitto is started with a config file path parameter.
The mqtt section of the docker-compose file that allows anonymous connections on port 1883 will be:
...
mqtt:
image: eclipse-mosquitto
ports:
- "1883:1883"
restart: always
command: ["/usr/sbin/mosquitto", "-c", "/mosquitto-no-auth.conf"]
...
Step 3.
go to somepath/ming
balena push <yourFleetName>
How do I edit the variables of mosquitto?
If you need a more sophisticated user:password authentication, please check this Authentication methods | Eclipse Mosquitto the password files section.
To utilise this tool you may need to specify your own dockerfile, that copies your mosquitto.conf into the service image. Then it’s on you to decide if you:
- want to create the password file during image build time with
mosquitto_passwd <password file> <username> <password>
or
- if you want to run the
mosquitto_passwd <password file> <username> <password>
in an entry.sh script to create a user:password at startup time from service / device environment variables.
How do I add or erase services?
Can you please share more details about this question, what do you mean by ‘erase services’?
Best Regards
Harald