質問編集履歴

7

文章の修正

2019/06/11 15:14

投稿

ishiatama
ishiatama

スコア11

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  - localhost:3000で通信できましたが、localhostだと上記のエラーになります。
24
24
 
25
- - Macにbrewでnginxをインストール同じconf設定にするとlocalhostで設定できることを確認しました。
25
+ - Macにbrewでnginxをインストールし、同じconf設定にするとlocalhostでWebページが表示されることを確認しました。
26
26
 
27
27
 
28
28
 

6

追記

2019/06/11 15:14

投稿

ishiatama
ishiatama

スコア11

test CHANGED
File without changes
test CHANGED
@@ -10,9 +10,23 @@
10
10
 
11
11
  Railsをコンテナではなく、ホスト(Mac)側に環境を作った際に、Nginxで`connect() to unix:///var/www/myapp/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:///var/www/myapp/tmp/sockets/puma.sock:/", host: "localhost"`のエラーが発生し通信できません。
12
12
 
13
- ~~そもそもホストとコンテナ間でsocket通信は可能なのでしょうか?~~
13
+ そもそもホストとコンテナ間でsocket通信は可能なのでしょうか?
14
+
15
+
16
+
14
-
17
+ ---
18
+
19
+
20
+
21
+ 追記
22
+
15
- localhost:3000で通信できましたが、localhostだと上記のエラーになります。
23
+ - localhost:3000で通信できましたが、localhostだと上記のエラーになります。
24
+
25
+ - Macにbrewでnginxをインストールに同じconf設定にするとlocalhostで設定できることを確認しました。
26
+
27
+
28
+
29
+ ---
16
30
 
17
31
 
18
32
 

5

修正

2019/06/11 15:11

投稿

ishiatama
ishiatama

スコア11

test CHANGED
File without changes
test CHANGED
@@ -58,6 +58,14 @@
58
58
 
59
59
  - 80:80
60
60
 
61
+ volumes:
62
+
63
+ - ./public:/var/www/myapp/public
64
+
65
+ - ./tmp:/var/www/myapp/tmp
66
+
67
+ - ./log:/var/www/myapp/log
68
+
61
69
  environment:
62
70
 
63
71
  TZ: Asia/Tokyo

4

修正

2019/06/11 14:06

投稿

ishiatama
ishiatama

スコア11

test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  # docker-compose.yml
26
26
 
27
- version: '2.4'
27
+ version: '2'
28
28
 
29
29
  services:
30
30
 
@@ -50,84 +50,6 @@
50
50
 
51
51
  - ./data/pg-data:/var/lib/postgresql/data
52
52
 
53
- # rails: &app_base
54
-
55
- # build: .
56
-
57
- # command: bash -c "dockerize -wait tcp://postgres:5432 -timeout 3m && bundle exec puma"
58
-
59
- # volumes:
60
-
61
- # - .:/var/www/workspace
62
-
63
- # # - ./data/bundle-data:/var/www/workspace/vendor/bundle
64
-
65
- # - ./data/bundle-data:/usr/local/bundle
66
-
67
- # ports:
68
-
69
- # - "3000:3000"
70
-
71
- # # ruby-debug-ide 用
72
-
73
- # - "1234:1234"
74
-
75
- # - "26162:26162"
76
-
77
- # environment:
78
-
79
- # # BUNDLE_PATH: /var/www/workspace/vendor/bundle
80
-
81
- # BUNDLE_APP_CONFIG: /var/www/workspace/.bundle
82
-
83
- # TZ: Asia/Tokyo
84
-
85
- # stdin_open: true
86
-
87
- # tty: true
88
-
89
- # depends_on:
90
-
91
- # - postgres
92
-
93
- # links:
94
-
95
- # - postgres
96
-
97
- # spring:
98
-
99
- # <<: *app_base
100
-
101
- # ports: []
102
-
103
- # command: bash -c "dockerize -wait tcp://postgres:5432 -timeout 3m && bundle exec spring server"
104
-
105
- # stdin_open: true
106
-
107
- # tty: true
108
-
109
- # pid: host
110
-
111
- # environment:
112
-
113
- # # BUNDLE_PATH: /var/www/workspace/vendor/bundle
114
-
115
- # BUNDLE_APP_CONFIG: /var/www/workspace/.bundle
116
-
117
- # DATABASE_URL: postgres://devuser:password@postgres:5432
118
-
119
- # SPRING_SOCKET: /tmp/spring/spring.sock
120
-
121
- # volumes:
122
-
123
- # - .:/var/www/workspace
124
-
125
- # # - ./data/bundle-data:/var/www/workspace/vendor/bundle
126
-
127
- # - ./data/bundle-data:/usr/local/bundle
128
-
129
- # - spring:/tmp/spring
130
-
131
53
  nginx:
132
54
 
133
55
  build: ./containers/nginx
@@ -136,16 +58,6 @@
136
58
 
137
59
  - 80:80
138
60
 
139
- volumes:
140
-
141
- - ./public:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/public
142
-
143
- - ./tmp:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/tmp
144
-
145
- - ./shared:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/shared
146
-
147
- - ./log:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/log
148
-
149
61
  environment:
150
62
 
151
63
  TZ: Asia/Tokyo
@@ -154,12 +66,6 @@
154
66
 
155
67
  - postgres
156
68
 
157
- # volumes:
158
-
159
- # spring:
160
-
161
-
162
-
163
69
  ```
164
70
 
165
71
 

3

docker-compose.yml追加

2019/06/11 14:04

投稿

ishiatama
ishiatama

スコア11

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,150 @@
20
20
 
21
21
 
22
22
 
23
+ ```
24
+
25
+ # docker-compose.yml
26
+
27
+ version: '2.4'
28
+
29
+ services:
30
+
31
+ postgres:
32
+
33
+ image: postgres
34
+
35
+ ports:
36
+
37
+ - 5432:5432
38
+
39
+ environment:
40
+
41
+ POSTGRES_USER: devuser
42
+
43
+ POSTGRES_PASSWORD: password
44
+
45
+ POSTGRES_DB: dev
46
+
47
+ volumes:
48
+
49
+ - ./containers/postgresql/init.sh:/docker-entrypoint-initdb.d/init.sh
50
+
51
+ - ./data/pg-data:/var/lib/postgresql/data
52
+
53
+ # rails: &app_base
54
+
55
+ # build: .
56
+
57
+ # command: bash -c "dockerize -wait tcp://postgres:5432 -timeout 3m && bundle exec puma"
58
+
59
+ # volumes:
60
+
61
+ # - .:/var/www/workspace
62
+
63
+ # # - ./data/bundle-data:/var/www/workspace/vendor/bundle
64
+
65
+ # - ./data/bundle-data:/usr/local/bundle
66
+
67
+ # ports:
68
+
69
+ # - "3000:3000"
70
+
71
+ # # ruby-debug-ide 用
72
+
73
+ # - "1234:1234"
74
+
75
+ # - "26162:26162"
76
+
77
+ # environment:
78
+
79
+ # # BUNDLE_PATH: /var/www/workspace/vendor/bundle
80
+
81
+ # BUNDLE_APP_CONFIG: /var/www/workspace/.bundle
82
+
83
+ # TZ: Asia/Tokyo
84
+
85
+ # stdin_open: true
86
+
87
+ # tty: true
88
+
89
+ # depends_on:
90
+
91
+ # - postgres
92
+
93
+ # links:
94
+
95
+ # - postgres
96
+
97
+ # spring:
98
+
99
+ # <<: *app_base
100
+
101
+ # ports: []
102
+
103
+ # command: bash -c "dockerize -wait tcp://postgres:5432 -timeout 3m && bundle exec spring server"
104
+
105
+ # stdin_open: true
106
+
107
+ # tty: true
108
+
109
+ # pid: host
110
+
111
+ # environment:
112
+
113
+ # # BUNDLE_PATH: /var/www/workspace/vendor/bundle
114
+
115
+ # BUNDLE_APP_CONFIG: /var/www/workspace/.bundle
116
+
117
+ # DATABASE_URL: postgres://devuser:password@postgres:5432
118
+
119
+ # SPRING_SOCKET: /tmp/spring/spring.sock
120
+
121
+ # volumes:
122
+
123
+ # - .:/var/www/workspace
124
+
125
+ # # - ./data/bundle-data:/var/www/workspace/vendor/bundle
126
+
127
+ # - ./data/bundle-data:/usr/local/bundle
128
+
129
+ # - spring:/tmp/spring
130
+
131
+ nginx:
132
+
133
+ build: ./containers/nginx
134
+
135
+ ports:
136
+
137
+ - 80:80
138
+
139
+ volumes:
140
+
141
+ - ./public:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/public
142
+
143
+ - ./tmp:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/tmp
144
+
145
+ - ./shared:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/shared
146
+
147
+ - ./log:/Users/makoto/workspace/ghq/github.com/iFamcojp/piasen/log
148
+
149
+ environment:
150
+
151
+ TZ: Asia/Tokyo
152
+
153
+ depends_on:
154
+
155
+ - postgres
156
+
157
+ # volumes:
158
+
159
+ # spring:
160
+
161
+
162
+
163
+ ```
164
+
165
+
166
+
23
167
  ```Dockerfile
24
168
 
25
169
  FROM nginx

2

現状の更新

2019/06/11 14:01

投稿

ishiatama
ishiatama

スコア11

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,9 @@
10
10
 
11
11
  Railsをコンテナではなく、ホスト(Mac)側に環境を作った際に、Nginxで`connect() to unix:///var/www/myapp/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:///var/www/myapp/tmp/sockets/puma.sock:/", host: "localhost"`のエラーが発生し通信できません。
12
12
 
13
- そもそもホストとコンテナ間でsocket通信は可能なのでしょうか?
13
+ ~~そもそもホストとコンテナ間でsocket通信は可能なのでしょうか?~~
14
+
15
+ localhost:3000で通信できましたが、localhostだと上記のエラーになります。
14
16
 
15
17
 
16
18
 

1

誤字修正

2019/06/11 08:52

投稿

ishiatama
ishiatama

スコア11

test CHANGED
@@ -1 +1 @@
1
- RailsとNginxのUNIX SOCKET通信について
1
+ RailsとNginxのUNIX DOMAIN SOCKETについて
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 実現したいこと
2
2
 
3
- ホスト上のRailsとコンテナ上のNginxをUNIX SOCKET通信で連携させたい
3
+ ホスト上のRailsとコンテナ上のNginxをUNIX DOMAIN SOCKETで連携させたい
4
4
 
5
5
 
6
6