docker-composeで固定IPを割り振って起動を試みた
doncker-compose.yml
version: '3.3'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
networks:
app_net:
ipv4_address: 172.30.0.3
environment:
- WORDPRESS_DB_PASSWORD
- TZ
mysql:
image: mariadb-10.3.8:05
build: .
restart: always
networks:
app_net:
ipv4_address: 172.30.0.2
environment:
- MYSQL_ROOT_PASSWORD=${WORDPRESS_DB_PASSWORD}
- TZ
networks:
app_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.30.0.0/24
gateway: 172.30.0.1
docker-compose up
したところERRORが発生
$ sudo docker-compose up -d
RROR: The Compose file './docker-compose.yml' is invalid because:
networks.app_net.ipam.config value Additional properties are not allowed ('gateway' was unexpected)
調査してみると
compose file version3よりgatewayの項目は指定できなくなっているので
コメントアウトして再度docker-compose up
docker-compose.yml
version: '3.3'
services:
--------------------------省略-------------------
networks:
app_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.30.0.0/24
# gateway: 172.30.0.1 <-----コメントアウト
$ sudo docker-compose up -d
Creating compose_wordpress_wordpress_1 ... done
Creating compose_wordpress_mysql_1 ... done
今度はうまくいきました。