LoginSignup
3
8

More than 3 years have passed since last update.

Dockerfileのportsとexposeの違い

Posted at

ports

  • ホスト側のポートとコンテナ側のポートをマッピングする
  • ホスト側:コンテナ側

ports:
  - "3000:3000"

expose

  • コンテナ側のポートを指定
  • ホストには公開されず、docker0の仮想ブリッジネットワークにのみ公開される

expose:
  - "3000"

docker0

8: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:b9:e5:cd:08 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
3
8
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
3
8