1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

(ユーザ定義の) Docker Networkチートシート

Last updated at Posted at 2020-01-04

何回も調べなおしているのでメモを兼ねて
(特にdocker-composeでのネットワーク指定パターン)

ネットワークの作成方法

docker network create -d bridge --gateway=192.168.0.1 --subnet=192.168.0.0/16 <ネットワーク名>

docker run時の指定方法

docker run --net=<ネットワーク名>

Docker composeからの利用方法

IPアドレスを指定して使う

services:
  my-service:
    ~~~
    networks:
      default:
        ipv4_address: 192.168.0.1

networks:
  default:
    external:
      name: <ネットワーク名>

IPアドレス自動割り当てで使う

services:
  my-service:
    ~~~
    networks:
      - <ネットワーク名>

networks:
  <ネットワーク名>:
    external: true
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?