@@ -29,6 +29,7 @@ module.exports = (api, options) => {
29
29
30
30
// although this is primarily a dev server, it is possible that we
31
31
// are running it in a mode with a production env, e.g. in E2E tests.
32
+ const isInContainer = checkInContainer ( )
32
33
const isProduction = process . env . NODE_ENV === 'production'
33
34
34
35
const path = require ( 'path' )
@@ -185,12 +186,17 @@ module.exports = (api, options) => {
185
186
const networkUrl = publicUrl
186
187
? publicUrl . replace ( / ( [ ^ / ] ) $ / , '$1/' )
187
188
: urls . lanUrlForTerminal
189
+
188
190
console . log ( )
189
- console . log ( [
190
- ` App running at:` ,
191
- ` - Local: ${ chalk . cyan ( urls . localUrlForTerminal ) } ${ copied } ` ,
192
- ` - Network: ${ chalk . cyan ( networkUrl ) } `
193
- ] . join ( '\n' ) )
191
+ console . log ( ` App running at:` )
192
+ console . log ( ` - Local: ${ chalk . cyan ( urls . localUrlForTerminal ) } ${ copied } ` )
193
+ if ( ! isInContainer ) {
194
+ console . log ( ` - Network: ${ chalk . cyan ( networkUrl ) } ` )
195
+ } else {
196
+ console . log ( )
197
+ console . log ( chalk . yellow ( ` It seems you are running Vue CLI inside a container.` ) )
198
+ console . log ( chalk . yellow ( ` Access the dev server via ${ protocol } ://localhost:<your container's external mapped port>.` ) )
199
+ }
194
200
console . log ( )
195
201
196
202
if ( isFirstCompile ) {
@@ -254,6 +260,15 @@ function addDevClientToEntry (config, devClient) {
254
260
}
255
261
}
256
262
263
+ // https://stackoverflow.com/a/20012536
264
+ function checkInContainer ( ) {
265
+ const fs = require ( 'fs' )
266
+ if ( fs . existsSync ( `/proc/1/cgroup` ) ) {
267
+ const content = fs . readFileSync ( `/proc/1/cgroup` , 'utf-8' )
268
+ return / : \/ ( l x c | d o c k e r ) \/ / . test ( content )
269
+ }
270
+ }
271
+
257
272
module . exports . defaultModes = {
258
273
serve : 'development'
259
274
}
0 commit comments