0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

dockerの3000ポートが何故か外からみれてしまう。ufwで制限してもだめ

Last updated at Posted at 2025-08-14

nginx→ railsの構成でなぜかこれがアクセスできてしまう。

https://xxxx:3000/

原因は以下

    ports:
      - "3000:3000"

ufwで制限していてもdockerは特別扱いらしい
なのでdocker同士でしかみれない以下の設定に変更

    expose:
      - "3000"

また , exposeすると別の docker-compose.ymlからはみれないらしい
共通のネットワークを作成し、それぞれサービスに所属させる処置が必要らしい。

両方のdocker-compose.ymlに以下追加

networks:
  shared_net:
    external: true

各サービスを上記ネットワークに所属させる

services:
  nginx:
    image: nginx:latest
    expose:
      - "8080"
    networks:
      - shared_net
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?