What’s going on YouTube?
Recently a viewer posted a question:
Why would I not always want the same IP. Why would I want to virtualize something and then don’t know how to access it.
From what I understand about LXC, it is just a low-level service that is utilized by container engines like Docker and LXD, so I will gear my response in relation to Docker.
Given the nature of what can be virtualized, I believe Docker wanted to deliver a simplified container so that it can be as flexible as possible. When you start thinking about other services such as MySQL, Squid, and Apache; you normally would have to configure them to suit your use-case after installing those services. What makes Docker so powerful is that we are able to customize our Docker environment to suit our use-cases. Docker supports different types of network configurations depending on what we need:
Do you need to have multiple containers to communicate with each other? Then we can use a “bridge” network.
Do you want to do a Docker swarm setup? Then we can use an “overlay” network.
Do you want something similar to a VM setup? Then we can use a “macvlan” network.
When we are creating our containers, we can specify what network and IP address to use. While the default Docker bridge network does not support static IP addresses, we can create our own bridge network that will allow us to assign static IP addresses to our containers.
Not only that, we can map selected host ports to our container. So when it comes to networking, Docker has a few configurations that we can use.
Outside of our networking solutions, we have another option to connect to our Docker containers and that is by using the command line interface. We can connect to it by using the "docker exec" or "docker attach" commands. That will allow us to use our terminal, console or command prompt to connect to our containers. The advantage of using the CLI, is that we do not need to know the IP of the container, just the name of it. This is something I use quite often.
When it comes to debugging or error logging, we can use the "docker logs" command and hope that the information we are looking for is present within the output of the logs.
To recap, Docker does not assign static ip addresses because it expects us to set up the containers just the way we want it. To maintain its flexibility, it relies on us to do the leg work to configure the network just the way we need it.
Смотрите видео User Question #2: Docker IP Logic онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь WebDev Dave 04 Январь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 88 раз и оно понравилось 1 людям.