質問編集履歴
2
ネットワークの部分を修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -152,7 +152,7 @@
|
|
152
152
|
|
153
153
|
networks:
|
154
154
|
|
155
|
-
|
155
|
+
hoge_network:
|
156
156
|
|
157
157
|
external: true
|
158
158
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,3 +47,119 @@
|
|
47
47
|
Docker version 19.03.11, build 42e35e61f3
|
48
48
|
|
49
49
|
```
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
### 追記
|
54
|
+
|
55
|
+
```Dockerfile
|
56
|
+
|
57
|
+
FROM golang
|
58
|
+
|
59
|
+
WORKDIR /app
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
EXPOSE 80
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# waitライブラリの追加
|
68
|
+
|
69
|
+
ADD /wait /wait
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
RUN go get -u github.com/go-sql-driver/mysql\
|
74
|
+
|
75
|
+
github.com/gorilla/sessions&&\
|
76
|
+
|
77
|
+
chmod +x /wait&&\
|
78
|
+
|
79
|
+
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
ADD ./app /app
|
86
|
+
|
87
|
+
CMD [ "go","run","main.go" ]
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```docker-compose.yml
|
94
|
+
|
95
|
+
version: "3"
|
96
|
+
|
97
|
+
services:
|
98
|
+
|
99
|
+
mysql:
|
100
|
+
|
101
|
+
build: ./mysql
|
102
|
+
|
103
|
+
container_name: mysql
|
104
|
+
|
105
|
+
volumes:
|
106
|
+
|
107
|
+
- ./mysql/db:/docker-entrypoint-initdb.d
|
108
|
+
|
109
|
+
environment:
|
110
|
+
|
111
|
+
MYSQL_ROOT_PASSWORD: hogehoge
|
112
|
+
|
113
|
+
MYSQL_DATABASE: hoge_db
|
114
|
+
|
115
|
+
MYSQL_USER: hoge
|
116
|
+
|
117
|
+
MYSQL_PASSWORD: hogehoge
|
118
|
+
|
119
|
+
networks:
|
120
|
+
|
121
|
+
- hoge_network
|
122
|
+
|
123
|
+
ports:
|
124
|
+
|
125
|
+
- "33060:3306"
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
go_app:
|
130
|
+
|
131
|
+
build: ./go
|
132
|
+
|
133
|
+
container_name: go_app
|
134
|
+
|
135
|
+
networks:
|
136
|
+
|
137
|
+
- hoge_network
|
138
|
+
|
139
|
+
ports:
|
140
|
+
|
141
|
+
- "8080:80"
|
142
|
+
|
143
|
+
depends_on:
|
144
|
+
|
145
|
+
- mysql
|
146
|
+
|
147
|
+
environment:
|
148
|
+
|
149
|
+
WAIT_HOSTS: mysql
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
networks:
|
154
|
+
|
155
|
+
production_network:
|
156
|
+
|
157
|
+
external: true
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
実行時のコマンドは`docker-compose build`でした
|