Skip to content

Instantly share code, notes, and snippets.

@sanoyo
Last active August 17, 2019 00:19
Show Gist options
  • Save sanoyo/a6c5cf4a04f9fa12f6eca79cfca3c25e to your computer and use it in GitHub Desktop.
Save sanoyo/a6c5cf4a04f9fa12f6eca79cfca3c25e to your computer and use it in GitHub Desktop.
docker メモ

Docker メモ

メモ

docker ネットワーク

  • ホストにdoccker0というブリッジが作成される
  • コンテナにeth、ホストにvethがあり、これらがつながっている

参考記事

localhostにつながらない

状況

docker-compose startしたら、railsがexitされる。

対応

ログの確認し、エラーの内容を確認する。
docker logs コンテナ名

コンテナが立ち上がっていない場合は、下記コマンドでimageでデバッグを行う。 docker run --rm -it [image name] /bin/bash
参考記事

# 下記のような状況
$ sudo docker-compose ps
    Name                   Command               State            Ports         
--------------------------------------------------------------------------------
rails_mysql_1   docker-entrypoint.sh mysql ...   Up       0.0.0.0:3306->3306/tcp
rails_rails_1   /bin/sh -c rm -rf tmp/pids ...   Exit 7                         

$ docker logs rails_rails_1
Could not find public_suffix-3.1.1 in any of the sources
Run `bundle install` to install missing gems.
Could not find public_suffix-3.1.1 in any of the sources
Run `bundle install` to install missing gems.

Dockerhubへのpush

docker push yosano/イメージ名
タグ付き
docker push yosano/イメージ名:タグ名

Dcoker port

  • Dcokerfileで指定する
ports:
 - "8080:80"
 
 # 左(8080)がホストのport
 # 右(80)は、コンテナ内のport(ポートフォワードする箇所)

ポートフォワード

ポートの紐付けというイメージ

参考になる記事

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment