I am an absolut noop and I hope to find some help here to learn more about docker. I hope you don’t mind these beginner questions. I played around a little bit on a raspberry pi 4b and have docker installed and its building a docker for running Homebridge. While using it I recognised that one of the functions I would like to use in Homebridge need the MIio plugin from npm.
Although I have watched a couple of videos and read about docker I am not sure how to realise it that my docker is build and the MIio plugin is available after restart and also after rebuilding the docker.
I assume that the best way would be to put the install miio command in the dockerfile and not in the yml. but I am not sure because the yml is using an image to build the Homebridge and I am getting confused if that image should not also be in the dockerfile as well.
If you need to extend the behavior of an image, usualy you end up writting your own Dockerfile. What you call yml is a docker-compose.yml. A service in a docker-compose.yml can have an image AND a build instruction at the same time. If both are provided, the image will be build whenever necessary and named like the image-repo:tag you used for image. You should make yourself aquinted with the Dockerfile reference and Docker compose file reference (stick with v2 unless you want to deploy to docker swarm)
By the way: if you build an image, it is an image, when start a container from an image, it is a container, non of both are “a docker”… Docker is “just” one of the engines that runs containers.
I was reading the links. Thanks.
Since I am still new to this - can I express my thoughts.
As I understand it the docker-compose file is a level higher than the dockerfiles. At least it’s good practice to use it that way. The dockerfiles have all the information to build a container from an image and the docker-compose controls the execution of e.g. multiple
In my setup I would like to create dockerfiles and docker-compose file so that a raspberry PI starts multiple containers and run them in parallel. In one container I would like to run homebridge and in another iobroker. The docker-compose would be used to create both containers at once. Good practice?
For that I think I should move the homebridge image to one of the dockerfiles and the iobroker image to the other dockerfile. As I learned the docker has to start with a „from“. How would the command continue if I want to build from the image oznu/homebridge:raspberry-pi?
A Dockerfile and a docker compose file have different objectivs. A Dockerfile is the blueprint of how an image is build. A docker-compose.yml is used to orchestrate the deployment for one or more container. Usualy you create a docker-compose.yml per concern/same purpose, e.g. if an app requires a database, both should be in the same docker-compose.yml; On the other side, even though putting all your containers into a single docker-compose.yml is considered bad practive, no one stops you from doing so…
You will only need to create your own Dockerfile/image if you customize/extend the behavior of the orginal image. With the FROM instruction you declare the base-image you want to use as a starting point for your customizations.
I am not sure what to make with this question. You should be the one knowing how you want to customize an image… The typical cycle is: “read the Dockerfil/compose file references, apply your changes to the files, try”, repeat untill you get stuck. If you get stuck, share the exact docker-compose.yml and/or Dockerfile together with logs of what appears to be a problem.