1
1

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 1 year has passed since last update.

MailHogのDockerコンテナを立ち上げる

Posted at

概要

  • DockerにてMailHogのDockerコンテナを起動する方法を簡単にまとめる。

方法

  1. 任意のディレクトリにdocker-compose.yml.docker/mailディレクトリを作成し、Dockerfileを作成する。階層をわかりやすく表すと下記のようになる。

    任意のディレクトリ
        └docker-compose.yml
        └.docker
            └mail
                └Dockerfile
    
  2. docker-compose.ymlを開き下記の内容を記載する。

    docker-compose.yml
    version: "3.8"
    
    services:
    
      mail:
        build:
          context: ./.docker/mail
          dockerfile: Dockerfile
        ports:
          - "8025:8025"
          - "1025:1025"
    
  3. Docker hubを確認してMailHogのイメージ情報を確認する。

  4. どうやら現在の最新バージョン(タグ)はv1.0.1のようだ。

    mailhog_mailhog_Tags___Docker_Hub.png

  5. 「latest」タグを使ってもいいが、コンテナ起動時期によってバージョンが変わると困るのでv1.0.1を指定することにする。

  6. Dockerfileを開き、下記のように記載する。

    .docker/mail/Dockerfile
    FROM mailhog/mailhog:v1.0.1
    
  7. docker-compose.yml.dockerがあるディレクトリで下記コマンドを実行してコンテナを起動する。

    docker-compose up -d
    
  8. 上記コマンドが無事実行されたら下記コマンドを実行し、起動中コンテナの中にMailHogのコンテナがあるか確認する。

    docker ps
    
  9. http://localhost:8025/にアクセスし下記スクショと近い画面が開くことを確認する。無事開けたら作業完了である。

    MailHog_と___main_-DokuPro-_Slack.png

1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?