r/docker icon

Go to docker

Docker Compose can I assign any ipv4 address?

Thumbnail image: How to responsibly select AI for your organization

Also, instead of hardcoded IP addresses to use for communication, you should look into network aliases for Docker containers. Docker has an internal DNS service which allows for you to reference a Docker container's IP address by either it's container name or network alias. This allows for you to not care about what IP address it is given.

So the idea would be that I don't have to know on the spot which IP addresses are taken. I'll read the documentation on that, thank you.

More replies More replies

You should be able to use any subnet on the bridge as long as the subnet isn't used on another interface on the host.

Thanks for the quick answer. I'll double check if that is the case.

More replies

Not sure if you have fixed the problem but this docker compose file will communicate between the wordpress and the maria db containers with no additional setup

wordpress:
  image: wordpress
  links:
    - wordpress_db:mysql
  ports:
    - 80:80
  volumes:
   - ./docker-runtime/wwwroot:/var/www/html
restart: always

wordpress_db:
  image: mariadb
  environment:
MYSQL_ROOT_PASSWORD: rootpass
 restart: always
  volumes:
- ./docker-runtime/sql:/var/lib/mysql