mercredi 27 mars 2019

Docker + EmberCLI + Windows = Not working

System overview

I am developing applications in Ember and I am not able to update the CLI to the most current version due to older applications are still in development (version 2.15). But I want to try to refactor some parts to ember 3.8.

Since I need a 3.8 ember CLI for this I tried to use a docker container for it so, that I can leave the working CLI on my system (v2.15) untouched.

I am using Docker Desktop CE V2.0.0.3 (31259) with Docker Engine 18.09.2. The package is: "danlynn/ember-cli:3.8.1". I am doing everything in a PowerShell with elevated rights. (The linux containers are run in a Moby image in Hyper-V)

On my system is no other container running during these tests/problem solvings:

PS C:\docker_ember> docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
PS C:\docker_ember>

What is working?

When I am running a container with a bash to be able to use the ember CLI, everything works fine - even "npm i" and "ember build":

PS C:\docker_ember> docker run --rm -ti -v ${PWD}:/myapp -p 4200:4200 -p 7020:7020 -p 7357:7357 danlynn/ember-cli:3.8.1 bash


root@a39fe0269e04:/myapp# npm i
npm WARN rollback Rolling back npm-bundled@1.0.5 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/myapp/node_modules/fsevents/node_modules/npm-bundled'
npm WARN rollback Rolling back os-homedir@1.0.2 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/myapp/node_modules/fsevents/node_modules/os-homedir'
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 64805 packages in 61.406s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details


root@a39fe0269e04:/myapp# ember build
Environment: development

ember38/templates/index.hbs
  2:4  error  Incorrect indentation for `<div>` beginning at L2:C4. Expected `<div>` to be at an indentation of 2 but was found at 4.  block-indentation
  3:8  error  Incorrect indentation for `` beginning at L3:C8. Expected `` to be at an indentation of 6 but was found at 8.  block-indentation

===== 1 Template Linting Error

cleaning up...
Built project successfully. Stored in "dist/".


root@a39fe0269e04:/myapp#

What is not working?

But the problem is, and I am not able to find the reason for it: "ember server"/"ember s" will not work. After some starting time the console just sais:

Port 4200 is already in use.

But it is not. I have checked every port on windows and in the container - its free. I even changed the port in the .ember-cli config file to other port without even leaving the container (I tried >10) - all are "in use".

I tried other variants of the docker command - even one without any port exposing:

docker run --rm -ti -v ${PWD}:/myapp -p 4200:4200 -p 7020:7020 -p 7357:7357 danlynn/ember-cli:3.8.1 bash

docker run --rm -ti -v ${PWD}:/myapp -p 4200:4200 -p 7020:7020 -p 7357:7357 --add-host=localhost:172.18.80.177 danlynn/ember-cli:3.8.1 bash

docker run --rm -ti -v ${PWD}:/myapp --network="host" danlynn/ember-cli:3.8.1 bash

docker run --rm -ti -v ${PWD}:/myapp --net=host --pid=host --privileged danlynn/ember-cli:3.8.1 bash

docker run --rm -ti -v ${PWD}:/myapp -p 4200 -p 7020 -p 7357 danlynn/ember-cli:3.8.1 bash

# This one replaces the bash with a real ember CLI command.
docker run --rm -ti -v ${PWD}:/myapp -p 4200:4200 -p 7020:7020 -p 7357:7357 danlynn/ember-cli:3.8.1 ember s

So I tried some other container, that opens ports - NGINX:

PS C:\docker_ember> docker run --rm -ti -p 80:80 nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
27833a3ba0a5: Pull complete
e83729dd399a: Pull complete
ebc6a67df66d: Pull complete
Digest: sha256:dff6326b09c76bef1425ee64c2e218b38737cdb5412b8ccf84ca70740bfa1db2
Status: Downloaded newer image for nginx:latest
172.17.0.1 - - [27/Mar/2019:07:46:05 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" "-"
2019/03/27 07:46:06 [error] 8#8: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
172.17.0.1 - - [27/Mar/2019:07:46:06 +0000] "GET /favicon.ico HTTP/1.1" 404 556 "http://localhost/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" "-"
^C

PS C:\docker_ember>

It's just working flawlessly.

What have I tried to solve this problem?

  1. I resetted docker desktop to factory defaults. (this will even delete every image)
  2. I uninstalled the whole docker for windows software (that even deleted the moby image) - and reinstalled it, freshly downloaded from the docker hub.
  3. I deleted every hyper-v network adapter before reinstalling the docker desktop CE software.
  4. I tried to use a "pure" node 8 docker container and installed ember-cli@3.8.1 manually in it - but same result.
  5. I restarted windows many times.
  6. I resetted the whole windows network with using "netcfg -d". (that even removed every saved wifi key, etc.)

I am just out of options, since the port is not in use - change it and it is magically already in use AGAIN. The docker containers are able to open ports and use them: NGINX works flawlessly. I guess, there is some other reason preventing nodeJS ports from getting opened.

Any tips?




Aucun commentaire:

Enregistrer un commentaire