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 3 years have passed since last update.

既存ネットワークに後から作成したコンテナを接続する方法

Posted at

したいこと

  • 1つのdocker-compose.ymlに複数コンテナの記述をするのではなく、既存ネットワークに後から作成したコンテナを接続したい。

参考

作成

net1というネットワークを作成
docker create network net1

接続

docker-compose.yml
version: "3"
services:

  potmum:
    image: tukiyo3/potmum:20170807
    restart: always
    volumes:
     - /etc/localtime:/etc/localtime
     - ./db/production.sqlite3:/srv/potmum/db/production.sqlite3
     - ./attachment_files/:/srv/potmum/public/attachment_files/
    environment:
      PRIVATE_MODE: 0
      USE_ATTACHMENT_FILE: 1
      COLOR_THEME: "green"
      #
      USE_GITHUB: 0
      USE_DEVELOPER: 1

networks:
  default:
    external:
      name: net1
docker-compose.yml
version: "3"
services:

  nginx:
    image: nginx:alpine
    restart: always
    volumes:
      - ./nginx/htpasswd:/etc/nginx/htpasswd
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
    ports:
      - 80:80

networks:
  default:
    external:
      name: net1
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?