Answer the question
In order to leave comments, you need to log in
How to forward a static IP to a container?
Hello.
At the moment I run the container with --net host, and applications can occupy any IP available on the machine itself.
I need to limit this, while leaving the ability to occupy any ports on a dedicated IP.
Now if I write docker run --net host --ip 6.192.35.15, it gives me
docker: Error response from daemon: user specified IP address is supported on user defined networks only.
Error response from daemon: failed to allocate gateway (): No available addresses on this pool
Answer the question
In order to leave comments, you need to log in
forward the port inside the container and plus a rule to change the address for packets outgoing from the container.
Docker -compose will help you
Stop your containers
Create mycontainer.yml file
version: '2'
services:
myconteiner1: #Servicename
image: imagename/imagename:1.0
container_name: container-name1
user: root
networks:
net: - #Это имя сети
ipv4_address: 172.19.0.2
myconteiner2: #Servicename
image: imagename/imagename:1.0
container_name: container-name2
user: root
networks:
net: - #Это имя сети
ipv4_address: 172.19.0.3
networks:
net: - #Это имя сети
driver: bridge
ipam:
driver: default
config:
- subnet: 172.19.0.0/24
driver_opts:
com.docker.network.bridge.name: common-bridge -# Это имя моста
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question