vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.33k forks source link

checkInContainer not working on latest Docker version #6871

Open adrienWeiss opened 2 years ago

adrienWeiss commented 2 years ago

Version

4.5.11

Environment info

Environment Info:

  System:
    OS: Linux 5.10 Alpine Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @ant-design-vue/babel-helper-vue-transform-on:  1.0.1 
    @johmun/vue-tags-input: ^2.1.0 => 2.1.0 
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.5.4 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.5.4 
    @vue/cli-plugin-babel: ^4.5.4 => 4.5.4 
    @vue/cli-plugin-eslint: ^4.5.4 => 4.5.4 
    @vue/cli-plugin-pwa: ^4.5.11 => 4.5.11 
    @vue/cli-plugin-router:  4.5.4 
    @vue/cli-plugin-unit-jest: ^4.5.4 => 4.5.4 
    @vue/cli-plugin-vuex:  4.5.4 
    @vue/cli-service: ^4.5.4 => 4.5.4 
    @vue/cli-shared-utils:  4.5.4 (4.5.11)
    @vue/component-compiler-utils:  3.2.0 
    @vue/composition-api: ^1.0.0-beta.22 => 1.0.0-beta.22 
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 
    @vue/preload-webpack-plugin:  1.1.2 
    @vue/test-utils: ^1.0.5 => 1.0.5 
    @vue/web-component-wrapper:  1.2.0 
    @websanova/vue-auth: ^4.1.1 => 4.1.1 
    announcekit-vue: ^2.0.3 => 2.0.3 
    eslint-plugin-vue: ^6.2.2 => 6.2.2 
    idle-vue: 2.0.5 => 2.0.5 
    jest-serializer-vue:  2.0.2 
    simplebar-vue: ^1.6.0 => 1.6.0 
    vue: ^2.6.12 => 2.6.12 
    vue-analytics: ^5.22.1 => 5.22.1 
    vue-apollo: ^3.0.4 => 3.0.4 
    vue-async-computed: ^3.9.0 => 3.9.0 
    vue-avatar: ^2.3.0 => 2.3.0 
    vue-axios: ^3.2.4 => 3.2.4 
    vue-class-component:  7.2.5 (7.2.6)
    vue-cli-plugin-vuetify: ^2.3.1 => 2.3.1 
    vue-demi:  0.5.3 
    vue-eslint-parser:  7.0.0 
    vue-focus: ^2.1.0 => 2.1.0 
    vue-fusioncharts: 3.1.0 => 3.1.0 
    vue-hot-reload-api:  2.3.4 
    vue-i18n: ^8.21.0 => 8.21.0 
    vue-jest:  3.0.6 
    vue-js-toggle-button: ^1.3.3 => 1.3.3 
    vue-loader:  15.9.3 (16.8.1)
    vue-mapbox: ^0.4.1 => 0.4.1 
    vue-observe-visibility:  0.4.6 
    vue-phone-number-input: ^1.1.10 => 1.1.10 
    vue-property-decorator:  8.5.1 (9.0.2)
    vue-resize:  0.4.5 
    vue-router: ^3.5.2 => 3.5.2 
    vue-runtime-helpers:  1.1.2 
    vue-select: ^3.10.8 => 3.10.8 
    vue-shadow-dom: ^1.5.0 => 1.5.0 
    vue-slider-component: ^3.2.5 => 3.2.5 
    vue-style-loader:  4.1.2 
    vue-svgicon: ^3.2.6 => 3.2.6 
    vue-template-compiler: ^2.6.12 => 2.6.12 
    vue-template-es2015-compiler:  1.9.1 
    vue-upload-component: ^2.8.20 => 2.8.20 
    vue-virtual-scroller:  1.0.10 
    vuedraggable: ^2.24.1 => 2.24.1 
    vuejs-paginate: ^2.1.0 => 2.1.0 
    vuetify: ^2.4.11 => 2.4.11 
    vuetify-loader: ^1.7.2 => 1.7.2 
    vuex: ^3.5.1 => 3.5.1 
    vuex-persist: ^3.1.3 => 3.1.3 
    vuex-router-sync: ^5.0.0 => 5.0.0 
  npmGlobalPackages:
    @vue/cli: 4.5.11

Steps to reproduce

checkInContainer function in cli-service/lib/commands/serve.js is relying on a regex check in /proc/1/cgroup to determine if it is running inside a container. Docker now uses cgroup v2 https://docs.docker.com/desktop/mac/release-notes/#bug-fixes-and-minor-changes which states

On cgroup v2 hosts, the content of /proc/cgroups isn’t meaningful. See /sys/fs/cgroup/cgroup.controllers to the available controllers. (https://docs.docker.com/config/containers/runmetrics/)

From my understanding, checking the content of /proc/1/cgroup is not a reliable way of checking if the command is running inside a container anymore. The only workaround I have at the moment is setting the CODESANDBOX_SSE env variable in my container.

What is expected?

App running at:
- Local:   https://localhost:9080/ 

It seems you are running Vue CLI inside a container.
Access the dev server via https://localhost:<your container's external mapped port>/

What is actually happening?

App running at:
- Local:   https://localhost:9080/ 
- Network: https://172.25.0.5:9080/
christian-kolb commented 2 years ago

I've run into the same issue.

@adrienWeiss Thanks a lot for your workaround. Without it, my environment would be broken.

It's not really obvious that this due to the Vue CLI.

ccmetz commented 2 years ago

Thanks for the workaround! I'm running into this issue as well since I've upgraded docker.