M
M
MiyRon2021-07-04 15:32:10
Docker
MiyRon, 2021-07-04 15:32:10

Why doesn't the Docker container get a static ip?

Good day. I'm trying to bind a container with nginx to ip 172.16.238.10 but for some reason docker is ignoring the settings in docker-compose

#my docker-compose file
version: "3.9"

services:

nginx:
build: nginx/
ports:
- 80:80/tcp
volumes:
./dokcer/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
. /dokcer/nginx/conf/hosts:/etc/hosts
./docker/project:/var/www/project
networks:
app_net:
ipv4_address: 172.16.238.10

php-fpm:
build: php-fpm/
ports:
- 9000:9000 /tcp
volumes:
./dokcer/php-fpm/conf/www.conf:/usr/local/etc/php-fpm.d/www.conf
./dokcer/php-fpm/conf/hosts:/etc/hosts
./dokcer/project:/var/www/project
networks:
app_net:
ipv4_address: 172.16.238.11

networks:
app_net:
ipam:
driver: default
config:
- subnet : "172.16.238.0/24"


after building and running, I look at the docker_app_net network and see that the nginx container has an ip of 172.16.238.2, although I expected it to be 172.16.238.10.

What could be the problem? I will be grateful for every answer, because. confused :c

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question