Reputation: 433
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 [email protected] failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/myapp/node_modules/fsevents/node_modules/npm-bundled'
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/myapp/node_modules/fsevents/node_modules/os-homedir'
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: 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 `{{target.id}}` beginning at L3:C8. Expected `{{target.id}}` 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?
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?
Upvotes: 0
Views: 278
Reputation: 5231
That docker image already run ember server directly so you are probably trying to run ember server twice. If you check the dockerfile https://github.com/danlynn/ember-cli/blob/3.8.1/Dockerfile#L11 that line specify that if you run the image without any parameter will run ember server.
If you run the image with a name after you start it you can attach to the container:
$ docker run --name myapp --rm -ti -v $(pwd):/myapp -p 4200:4200 -p 7020:7020 -p 7357:7357 danlynn/ember-cli:3.8.1
Attach to the container running ember server:
$ docker exec -it myapp bash
Inside that you can just execute the commands you need in the container enviroment.
Upvotes: 0
Reputation: 6338
You have a wrong assumption in your use case. You don't need to have the same Ember CLI version installed globally as used in your project. Actually it's always using Ember CLI installed in project and defined by it's package.json
. It's only using globally installed Ember CLI if executed outside of an ember project. This is mostly used for creating new applications (ember new
) or addons (ember addon
). You could easily verify that feature yourself by printing out version of used Ember CLI (ember -v
) inside of an ember project and globally.
Upvotes: 2