Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker events fails on windows #56

Closed
Sureiya opened this issue Jul 30, 2019 · 51 comments
Closed

Docker events fails on windows #56

Sureiya opened this issue Jul 30, 2019 · 51 comments

Comments

@Sureiya
Copy link

Sureiya commented Jul 30, 2019

Currently this does not work with docker on windows.

Error: Error executing sub-child: docker events --format {{json .}} --filter image=selenium/standalone-chrome-debug

The following change to dockerEvents.js fixes it.

const DEFAULT_OPTIONS = {
  format: '"{{json .}}"'
};
@stsvilik
Copy link
Collaborator

@Sureiya strangely enough it fails on macOS :/ So you have tested with above change and it worked? The reason I ask is that above error can also appear when older version of Docker is installed (the one that doesn't support events).

@Sureiya
Copy link
Author

Sureiya commented Jul 31, 2019 via email

@stsvilik
Copy link
Collaborator

@Sureiya sorry for long delay - I'm in the middle of a house move, is there a way you could put together a PR for this fix?

@abhijit945
Copy link

abhijit945 commented Sep 17, 2019

Is there any workaround for this?
Edit:
OS: Windows 10
Terminal: Powershell or GitBash
Docker is already installed.

@serbanghita
Copy link
Collaborator

@Sureiya just to be sure, do you have Win 10 Pro? I need to know how to test this on a Windows VM

@Sureiya
Copy link
Author

Sureiya commented Sep 20, 2019

@serbanghita I am using Windows 10 Pro build 1903

@webOS101
Copy link

webOS101 commented Nov 10, 2019

I'm seeing the same issue running on Ubuntu 16.04.4. I had another installation that was working fine before on the same server but appears to not be working anymore.

Docker version 18.06.0-ce, build 0ffa825

However, the fix of adding the quotes did not fix the problem for me.

@webOS101
Copy link

I'm embarrassed to say that I made a little mistake and didn't have privileges to run docker. I must have been testing with running the docker image standalone before. Still having some issues but I did resolve that one at least.

@stsvilik
Copy link
Collaborator

@webOS101 you almost made me think that Docker has fixed that inconsistency - guess not :)

@stsvilik
Copy link
Collaborator

stsvilik commented Dec 4, 2019

@Sureiya and @webOS101 could you check the RC version on Windows to see if it fixes the problem?

@calltojohn
Copy link

calltojohn commented Dec 4, 2019

i see this on mac (10.13.6) running docker 2.1.0.4 (39773). engine 19.03.4.

using: wdio-docker-service 2.1.5-rc.0

2019-12-04T13:02:20.514Z INFO @wdio/cli:launcher: Run onPrepare hook
2019-12-04T13:02:20.531Z WARN wdio-docker-service: Connecting dockerEventsListener: 43
2019-12-04T13:02:20.537Z INFO wdio-docker-service: Cleaning up CID files
2019-12-04T13:02:20.555Z WARN wdio-docker-service: NOTE: Pulling image for the first time. Please be patient.
2019-12-04T13:02:20.601Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format={{json\ .}} --filter=image=selenium/standalone-chrome
    at DockerEventsListener._onMessage (/app/node_modules/wdio-docker-service/lib/utils/dockerEventsListener.js:67:21)
    at ChildProcess.emit (events.js:210:5)
    at ChildProcess.EventEmitter.emit (domain.js:475:20)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
2019-12-04T13:02:20.602Z WARN wdio-docker-service: Disconnecting dockerEventsListener: 43

@stsvilik
Copy link
Collaborator

stsvilik commented Dec 4, 2019 via email

@calltojohn
Copy link

yeah. 2.1.5-rc.0

@stsvilik
Copy link
Collaborator

stsvilik commented Dec 5, 2019

Would it be too much to ask for any of you to test my PR locally #64. I added a code to handle docker events command based on OS, but looks like it doesn't work. I'm not really setup now to test on Windows :(

@stsvilik
Copy link
Collaborator

stsvilik commented Jan 8, 2020

@calltojohn and @webOS101 I have tested latest RC 2.1.5-rc.1 on my Windows machine and it works fine - do you mind giving it another shot?

@webOS101
Copy link

webOS101 commented Jan 8, 2020

I don't use Windows and my problem was unrelated, it was a configuration error on my part.

@stsvilik
Copy link
Collaborator

stsvilik commented Jan 9, 2020

closing this issue for now

@stsvilik stsvilik closed this as completed Jan 9, 2020
@nvega-ms
Copy link

Hello! I just tested the latest RC 2.1.5-rc.1 on Windows, and I got the error :(

@stsvilik
Copy link
Collaborator

@nvega-ms do you mind sharing the error log? I'm testing on Windows 10 Pro 64 bit

@WeresForce
Copy link

Hi, @stsvilik , I just ran into this issue as well, here is log:
2020-01-28T16:57:09.039Z DEBUG @wdio/utils:initialiseServices: initialise wdio service "docker"
2020-01-28T16:57:09.240Z INFO @wdio/cli:launcher: Run onPrepare hook
2020-01-28T16:57:09.243Z DEBUG wdio-docker-service: Docker command: docker run --cidfile C:\autoTests\WebdriverIo\selenium_standalone_chrome_debug.cid --rm -p 4446:4444 --shm-size 2g selenium/standalone-chrome-debug
2020-01-28T16:57:09.252Z WARN wdio-docker-service: Connecting dockerEventsListener: 15304
2020-01-28T16:57:09.259Z INFO wdio-docker-service: Cleaning up CID files
2020-01-28T16:57:14.342Z WARN wdio-docker-service: NOTE: Pulling image for the first time. Please be patient.
2020-01-28T16:57:14.353Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format "{{json .}}" --filter image=selenium/standalone-chrome-debug
at DockerEventsListener._onMessage (C:\autoTests\WebdriverIo\node_modules\wdio-docker-service\lib\utils\dockerEventsListener.js:67:21)
at ChildProcess.emit (events.js:210:5)
at ChildProcess.EventEmitter.emit (domain.js:475:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
2020-01-28T16:57:14.356Z WARN wdio-docker-service: Disconnecting dockerEventsListener: 15304
2020-01-28T16:57:19.865Z ERROR wdio-docker-service: Failed to run container: Command 'docker,pull,selenium/standalone-chrome-debug' exited with code 1

Can You, please suggest ho could it be fixed?

@stsvilik
Copy link
Collaborator

@WeresForce the issue with Error: Error executing sub-child was addressed in the latest release. Do you mind sharing the version of wdio-docker-service and Windows version? Also make sure Docker is running on your machine, if not this could also cause errors.

@WeresForce
Copy link

@stsvilik yes, You are absolutely right, my bad, I missed that Docker has stopped on my machine. Thank You for help

@kumaramit-bhabra
Copy link

@stsvilik i am still getting this issue.. below is the error log for your reference

2020-01-29T21:16:40.765Z INFO @wdio/cli:launcher: Run onPrepare hook
2020-01-29T21:16:40.805Z WARN wdio-docker-service: Connecting dockerEventsListener: 44
2020-01-29T21:16:40.834Z INFO wdio-docker-service: Cleaning up CID files
2020-01-29T21:16:40.892Z WARN wdio-docker-service: NOTE: Pulling image for the first time. Please be patient.
2020-01-29T21:16:40.953Z INFO @wdio/local-runner: Start worker 0-0 with arg:
2020-01-29T21:16:41.343Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json\ .}} --filter image=selenium/standalone-chrome
at DockerEventsListener._onMessage (/usr/app/node_modules/wdio-docker-service/lib/utils/dockerEventsListener.js:67:21)
at ChildProcess.emit (events.js:223:5)
at ChildProcess.EventEmitter.emit (domain.js:475:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)

in package.josn i have got this as dependency
"wdio-docker-service": "^2.2.1",

I am running it on windows.. Can you please advise what's going wrong..

@kumaramit-bhabra
Copy link

@stsvilik below is the config in wdio.conf.js for service as docker..

services: ['docker'],
dockerLogs: './',
dockerOptions: {
image: 'selenium/standalone-chrome',
healthCheck: 'http://localhost:4444',
options: {
p: ['4444:4444'],
shmSize: '2g'
}
},

@stsvilik
Copy link
Collaborator

stsvilik commented Jan 29, 2020 via email

@kumaramit-bhabra
Copy link

kumaramit-bhabra commented Jan 29, 2020

@stsvilik Thanks for the prompt reply. I am using Windows 10 Pro.. Just to be clear, Below are the steps which i am doing
. Have written some tests using webdriverIO (language as javascript)
. Created the dockerfile file and build an image
Dockerfile

FROM node
WORKDIR /usr/app
COPY . .
RUN npm install

. Used the below command to run it in a container
docker run -it -d
. From the container run the command npm test to execute the test

That's when i am getting the issue as mentioned above..

Also, how i can check whether the docker service is running or not? Do i need to install docker within the container to make it work? I am new to docker so just trying to understand..

@stsvilik
Copy link
Collaborator

stsvilik commented Jan 30, 2020

@kumaramit-bhabra Docker service is installed on your machine and runs in the background. On Windows you should see a Docker icon in the toolbar. Dockerfile when its built and runs creates a VM with its own OS. Each running container can map ports of its internally running application on to the host machine. When you expose a port it becomes accessible on your localhost. For example you have a Dockerfile which inherits FROM node. Inside that container you can run your express app on port 8080. You can expose that internal port 8080 on to your localhost on any other port. For this you need to map ports with docker run -it -d -p 8080:8080 [image-name]. Once you see that you could hit localhost:8080 on your machine and see your express app being served, THEN you can run tests against it with this service :)

@kumaramit-bhabra
Copy link

@stsvilik thanks a lot for your inputs.

I deleted my Docker desktop and re-installed it again but still i am not able to run my test cases in the container..

After re-installing i am still getting the same issue ..
ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json\ .}} --filter image=selenium/standalone-chrome

Docker services are also up and running. Once you have some time can you please look into this..

@kumaramit-bhabra
Copy link

For reference the image is currently at docker hub amitbhabra/wdio_asos

@stsvilik
Copy link
Collaborator

@kumaramit-bhabra do you mind going to node and telling me what value you see for process.platform? Also in order for you to run tests against your container, you must expose ports. When you run you container locally, can you hit it on the port exposed?

@kumaramit-bhabra
Copy link

@stsvilik Below is the value printed on console
Value of opsys is win32.

When i checked the computer properties, it say it's 64 bit. I have tried by exposing the port 4444 but no luck..

@kumaramit-bhabra
Copy link

@stsvilik Below is the error log for your reference.. hope this might be useful

2020-01-31T13:46:00.326Z INFO @wdio/local-runner: Start worker 0-0 with arg:
2020-01-31T13:46:00.434Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json\ .}} --filter image=selenium/standalone-chrome
at DockerEventsListener._onMessage (/usr/app/node_modules/wdio-docker-service/lib/utils/dockerEventsListener.js:67:21)
at ChildProcess.emit (events.js:321:20)
at ChildProcess.EventEmitter.emit (domain.js:485:12)
at emit (internal/child_process.js:881:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
2020-01-31T13:46:00.444Z WARN wdio-docker-service: Disconnecting dockerEventsListener: 44
[0-0] 2020-01-31T13:46:01.619Z INFO @wdio/local-runner: Run worker command: run
[0-0] RUNNING in chrome - /tests/landingPageTest.js
[0-0] 2020-01-31T13:46:02.111Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-01-31T13:46:02.129Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session
[0-0] 2020-01-31T13:46:02.130Z INFO webdriver: DATA {
capabilities: { alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' }
}
[0-0] 2020-01-31T13:46:02.224Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
[0-0] 2020-01-31T13:46:02.224Z INFO webdriver: Retrying 1/3
2020-01-31T13:46:02.225Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session
2020-01-31T13:46:02.225Z INFO webdriver: DATA {
capabilities: { alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome' }

@stsvilik
Copy link
Collaborator

stsvilik commented Jan 31, 2020 via email

@prathameshnyt
Copy link

prathameshnyt commented Feb 4, 2020

Thanks @stsvilik. I know we are talking about Windows here. On my personal MAC everything works fine but I am getting same error:

2020-02-04T14:38:11.092Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json\ .}} --filter image=<image> with latest release while running the same tests as part of CI/CD pipeline. We are using https://drone.io/ and deployed using drone-terraform OS: CentOS Linux 7 x86_64". Can you please suggest?

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 4, 2020 via email

@prathameshnyt
Copy link

Hi @stsvilik , in case of my local MAC it's darwin and in case of CI it's linux . Please let me know in case you need any other information. Thanks for looking.

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020

@prathameshnyt thank you for that! As I don't have all possible environments to test on this sort of information is really important. I believe that core of this issue is in that difference between how Docker on different OS's works. I did not know that linux was also a subject to this issue as the CI this package tests run on is also a Linux OS. I will look into running more tests under various systems.

@prathameshnyt
Copy link

Thank you so much @stsvilik for looking into it.

Thanks,
Prathamesh

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020

@prathameshnyt apparently my refactoring of options serialization code few PR's ago also eliminated the need to format that docker events JSON option differently for different OS's (who knew). With that said please give a shot to my latest version 2.3.0. Hope this settles this issue once and for all (fingers crossed).

@VisuSubbaiyan
Copy link

#63, Still its not working for me.

@prathameshnyt
Copy link

Thanks @stsvilik. Getting same error with 2.3.0 version.

Thanks,
Prathamesh

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020 via email

@prathameshnyt
Copy link

I will check. Thanks.

@prathameshnyt
Copy link

I see the same error #63 (comment) Thanks, Prathamesh

@prathameshnyt
Copy link

prathameshnyt commented Feb 5, 2020

Maybe, it's not waiting for Docker to come up as per the healthCheck:

healthCheck: {
            url: 'http://localhost:4444',
            maxRetries: 3,
            inspectInterval: 2000,
            startDelay: 5000
        },

I killed docker application and started again on my local machine MAC, but before it starts completely, If I run the test, I am seeing above error.

Thanks,
Prathamesh

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020 via email

@prathameshnyt
Copy link

@stsvilik , can you please check if startDelay setting works for you? Thanks.

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 6, 2020

@prathameshnyt Yes it does. Here is how I set that

healthCheck: {
       url: 'http://localhost:4444',
       startDelay: 15000
},

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 6, 2020

@prathameshnyt One thing to note that service will try to use native docker healthcheck event to start testing earlier. What this means is if Dockerfile has HEALTHCHECK set and it signals in success, tests will not wait for artificial delay. Same also applies if Docker healthcheck is set via command line.

@prathameshnyt
Copy link

Ok, thanks. Not sure, why it's not waiting in my case. I have tried now with image: 'selenium/standalone-chrome-debug' I don't see HEALTHCHECK.

Thanks,
Prathamesh

@prathameshnyt
Copy link

prathameshnyt commented Feb 6, 2020

I see health-check adding-a-healthcheck-to-the-grid added to Base image Dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests