@@ -29,6 +29,7 @@ module.exports = (api, options) => {
2929
3030 // although this is primarily a dev server, it is possible that we
3131 // are running it in a mode with a production env, e.g. in E2E tests.
32+ const isInContainer = checkInContainer ( )
3233 const isProduction = process . env . NODE_ENV === 'production'
3334
3435 const path = require ( 'path' )
@@ -185,12 +186,17 @@ module.exports = (api, options) => {
185186 const networkUrl = publicUrl
186187 ? publicUrl . replace ( / ( [ ^ / ] ) $ / , '$1/' )
187188 : urls . lanUrlForTerminal
189+
188190 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+ }
194200 console . log ( )
195201
196202 if ( isFirstCompile ) {
@@ -254,6 +260,15 @@ function addDevClientToEntry (config, devClient) {
254260 }
255261}
256262
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+
257272module . exports . defaultModes = {
258273 serve : 'development'
259274}
0 commit comments