'How to allow DHCP server assign always the same IP address to a docker container

I have a QNAP (TS-451U) and would like to run a self-developed app on it. Since cross-compiling from my MacBook is not that easy and installing it neither, I decided to go with the QNAP Container Station.

Manually, building and deploying my application as a container worked, but I want to automate the whole process. Thus, I deployed a Gitlab CE instance on the container station. As far as I see, I need a Gitlab runner, too (should not be too hard).

Summary of my setup

I have actually two questions:

  1. How to allow the Router (a Fritz!Box) assign always the same IP address to the Gitlab container and my deployed application (I know how to give a MAC address always the same IP in my router). I already found a setting in the Container Station that allows giving the container a fixed IP address, but I would like to have the router giving the IP address to the container. This allows e.g. My Computer to resolve the Gitlab instance via name and not only via IP address.

  2. How to deploy "My Application" to the Container Station? Do I need a local registry? Are there other ways possible? Can I directly deploy into the Container Station? As you may have understood from the rest of the question, I am new and not too deep into the whole docker thing.

Thanks for any feedback.



Solution 1:[1]

I found it out myself:

  1. The QNAP Container Station interface did not allow to set a MAC address when directly creating a new container. However, if you first pull an image, and then create a container from it, there is an option to set a MAC address. This fixed MAC address can then be used to always assign the same IP to the container.

Edit: This seems to be the actually correct way of doing it: https://www.reddit.com/r/qnap/comments/e6qp6h/comment/f9w2wj2/?utm_source=share&utm_medium=web2x&context=3

  1. What I found out yet is that you need a registry to deploy a docker image locally.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1