LoginSignup
2
1

More than 1 year has passed since last update.

dockerコンテナに複数のドメイン名でアクセスする(Docker for Windows)

Posted at

Dockerコンテナにドメイン名でアクセスする場合jwilder/nginx-proxyを使うと簡単です。ここでは、1つのコンテナに複数のドメイン名でアクセスする方法を記載します。

docker-compose.yml
services:
  proxy:
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  app:
    build:
      context: ..
      dockerfile: ./docker/php/Dockerfile
    volumes:
      - ../app:/var/www/html
      - ./php/php.ini:/usr/local/etc/php/php.ini
    environment:
      - VIRTUAL_HOST=domain_1.local,domain_2.local,domain_3.local
      - VIRTUAL_PORT=8

環境変数のVIRTUAL_HOSTにカンマ区切りで書きます。

Multiple Hosts
If you need to support multiple virtual hosts for a container, you can separate each entry with commas. For example, foo.bar.com,baz.bar.com,bar.com and each host will be setup the same.

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1