Due to the default bridge network, the IP address will change after restarting the container. In some scenarios we want to fix the container IP address. Paste the docker-compose.yml file directly version: '2' services: nginx: image: nginx:1.13.12 container_name: nginx restart: always tty: true networks: extnetwork: ipv4_address: 172.19.0.2 networks: extnetwork: ipam: config: - subnet: 172.19.0.0/16 gateway: 172.19.0.1 illustrate:
In the above configuration, our nginx container has a fixed IP of 172.19.0.2 Example, custom network mode: version: '2' services: nginx: image: nginx:1.13.12 container_name: nginx restart: always networks: extnetwork: ports: - 80:80 volumes: - '/nginx/conf.d:/etc/nginx/conf.d' nginx2: image: nginx:1.13.12 container_name: nginx2 restart: always networks: extnetwork: ipv4_address: 172.19.0.2 db: image:mysql:5.7 container_name: db volumes: - /var/lib/mysql:/var/lib/mysql restart: always networks: extnetwork: ports: -3306:3306 environment: MYSQL_ROOT_PASSWORD: wordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: image: wordpress:latest container_name: wordpress depends_on: -db ports: - "8000:80" restart: always networks: extnetwork: environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress networks: extnetwork: ipam: config: - subnet: 172.19.0.0/16 gateway: 172.19.0.1 The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Avoiding Problems Caused by Closures in JavaScript
>>: Database query which object contains which field method statement
Are you still using rem flexible layout? Does it ...
Table of contents Preface Mysql case when syntax:...
1. Create a database: create data data _name; Two...
CPU Load and CPU Utilization Both of these can re...
Today, when I searched for a page on Baidu, becaus...
summary Project description format <img src=&q...
Contemporary web visual design has gone through th...
In the process of making web pages, it is inevita...
Table of contents Install jupyter Docker port map...
The default port number of the Windows server rem...
This article shares with you how to implement dra...
Achieve results html <div class="containe...
This article shares the installation tutorial of ...
Preface This article is quite detailed and even a...
Preface: As far as I know, currently CSS can only...