2

Someone asked the same question here - the problem is that it relates to version 2 which I am not using. Is it meanwhile possible to define a static subnet and a static IP address for each started container with docker-compose within the docker-compose.yml file?

4

Use the following docker-compose.yml in order to start your containers in a predefined network with static IPv4 addresses:

version: '3.5'
services:
  service1:
  image: service1:latest
  networks:
    service1_net:
      ipv4_address: 172.22.0.100
networks:
  service1_net:
    ipam:
      driver: default
      config:
        - subnet: 172.22.0.0/16
  • Works fine for me, also with v. 3.1. Indentation missing after service1: but cannot edit and indent, because the changes are only 4 spaces, but S.O. requires edits to be 6 characters at least. — I think the driver: ... line should be directly after service1_net:? – KajMagnus Jan 9 '19 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.