Apache2 in docker using IPv6
I'm trying to configure IPv6 on my docker container. I want to expose port 80 on my IPv6. But my website still not working on IPv6. How to check where is the problem? Maybe someone can find it in my config files:
docker-compose.yml:
version: '3'
services:
web:
container_name: ci4
build:
context: ./docker
ports:
- 80:80
volumes:
- ./:/var/www/html
Dockerfile
FROM php:7.4-apache
RUN apt-get update && apt-get install -y
COPY 000-default.conf /etc/apache2/sites-available/
COPY ports.conf /etc/apache2/
RUN a2enmod rewrite
RUN service apache2 restart
ports.conf:
Listen [::]:80
000-default.conf
<VirtualHost [::]:80>
DocumentRoot "/var/www/html/public/"
ServerName localhost
<Directory "/var/www/html/public/">
AllowOverride all
</Directory>
</VirtualHost>
Thanks for any help.
Enable IPv6 support
Before you can use IPv6 in Docker containers or swarm services, you need to enable IPv6 support in the Docker daemon. Afterward, you can choose to use either IPv4 or IPv6 (or both) with any container, service, or network.
Edit /etc/docker/daemon.json, set the ipv6 key to true and the fixed-cidr-v6 key to your IPv6 subnet. In this example we are setting it to 2001:db8:1::/64.
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
}
Save and restart docker
systemctl reload docker
You can now create networks with the --ipv6 flag and assign containers IPv6 addresses using the --ip6 flag.
https://docs.docker.com/config/daemon/ipv6/