Make WordPress Core

Opened 4 years ago

Closed 21 months ago

Last modified 21 months ago

#51898 closed defect (bug) (fixed)

Docker Env: Check that Docker is running before use

Reported by: cnspecialcolor's profile cnspecialcolor Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.2 Priority: low
Severity: minor Version:
Component: Build/Test Tools Keywords: good-first-bug has-patch commit
Focuses: Cc:

Description (last modified by SergeyBiryukov)

why do i get error when follow wordpress/wordpress-develop github repository README.md

HERE IS THE wordpress/wordpress-develop github repository README.md

HERE IS THE ERROR WITHOUT sudo:

arthur@Arthur:~/Desktop/wordpress-develop-master$ npm run env:start

WordPress@5.6.0 env:start
node ./tools/local-env/scripts/start.js

Traceback (most recent call last):
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "requests/adapters.py", line 449, in send
  File "urllib3/connectionpool.py", line 727, in urlopen
  File "urllib3/util/retry.py", line 403, in increment
  File "urllib3/packages/six.py", line 734, in reraise
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission         denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker/api/client.py", line 205, in _retrieve_server_version
  File "docker/api/daemon.py", line 181, in version
  File "docker/utils/decorators.py", line 46, in inner
  File "docker/api/client.py", line 228, in _get
  File "requests/sessions.py", line 543, in get
  File "requests/sessions.py", line 530, in request
  File "requests/sessions.py", line 643, in send
  File "requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 123, in perform_command
  File "compose/cli/command.py", line 69, in project_from_options
  File "compose/cli/command.py", line 132, in get_project
  File "compose/cli/docker_client.py", line 43, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 188, in __init__
  File "docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection     aborted.', PermissionError(13, 'Permission denied'))
[9808] Failed to execute script docker-compose
child_process.js:674
throw err;
^

Error: Command failed: docker-compose up -d wordpress-develop
at checkExecSyncError (child_process.js:635:11)
at execSync (child_process.js:671:15)
at Object.<anonymous> (/home/arthur/Desktop/wordpress-develop-master/tools/local->env/scripts/start.js:8:1)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
  status: 255,
  signal: null,
  output: [ null, null, null ],
  pid: 9806,
  stdout: null,
 stderr: null
}
npm ERR! code 1
npm ERR! path /home/arthur/Desktop/wordpress-develop-master
npm ERR! command failed
npm ERR! command sh -c node ./tools/local-env/scripts/start.js
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/arthur/.npm/_logs/2020-11-25T03_56_37_680Z-debug.log
arthur@Arthur:~/Desktop/wordpress-develop-master$ 

HERE IS THE ERROR WITH sudo:

arthur@Arthur:~/Desktop$ cd wordpress-develop-master
arthur@Arthur:~/Desktop/wordpress-develop-master$ sudo npm run env:start
[sudo] password for arthur: 

> WordPress@5.6.0 env:start
> node ./tools/local-env/scripts/start.js

Traceback (most recent call last):
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
PermissionError: [Errno 13] Permission denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "requests/adapters.py", line 449, in send
  File "urllib3/connectionpool.py", line 727, in urlopen
  File "urllib3/util/retry.py", line 403, in increment
  File "urllib3/packages/six.py", line 734, in reraise
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker/api/client.py", line 205, in _retrieve_server_version
  File "docker/api/daemon.py", line 181, in version
  File "docker/utils/decorators.py", line 46, in inner
  File "docker/api/client.py", line 228, in _get
  File "requests/sessions.py", line 543, in get
  File "requests/sessions.py", line 530, in request
  File "requests/sessions.py", line 643, in send
  File "requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 123, in perform_command
  File "compose/cli/command.py", line 69, in project_from_options
  File "compose/cli/command.py", line 132, in get_project
  File "compose/cli/docker_client.py", line 43, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 188, in __init__
  File "docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))
[804114] Failed to execute script docker-compose
child_process.js:674
    throw err;
    ^

Error: Command failed: docker-compose up -d wordpress-develop
    at checkExecSyncError (child_process.js:635:11)
    at execSync (child_process.js:671:15)
    at Object.<anonymous> (/home/arthur/Desktop/wordpress-develop-master/tools/local-env/scripts/start.js:8:1)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  status: 255,
  signal: null,
  output: [ null, null, null ],
  pid: 804112,
  stdout: null,
  stderr: null
}
npm ERR! code 1
npm ERR! path /home/arthur/Desktop/wordpress-develop-master
npm ERR! command failed
npm ERR! command sh -c node ./tools/local-env/scripts/start.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-11-30T01_42_06_367Z-debug.log
arthur@Arthur:~/Desktop/wordpress-develop-master$ 
my question is: what have done wrong ? here is the docker and npm version on my local machine, i am on kali linux

arthur@Arthur:~/Desktop/wordpress-develop-master$ docker --version
Docker version 19.03.13, build 4484c46
arthur@Arthur:~/Desktop/wordpress-develop-master$ npm -v
7.0.3
arthur@Arthur:~/Desktop/wordpress-develop-master$ 

Attachments (2)

51898.diff (823 bytes) - added by mkox 3 years ago.
Added check if docker server is running
51898.2.diff (798 bytes) - added by mkox 3 years ago.
Removed tmp var

Download all attachments as: .zip

Change History (27)

#1 follow-up: @SergeyBiryukov
4 years ago

  • Component changed from General to Build/Test Tools
  • Description modified (diff)

Hi there, welcome to WordPress Trac! Thanks for the report.

I've edited the description to make it a bit more readable.

#2 in reply to: ↑ 1 @cnspecialcolor
4 years ago

THANKS !

Last edited 4 years ago by cnspecialcolor (previous) (diff)

#3 @pento
3 years ago

I ran into this error today, for me it was caused by Docker being installed, but not running.

Checking that docker info returns Server data before running commands would function as a reliable sanity check.

#4 @pento
3 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from normal to low
  • Severity changed from normal to minor

#5 @pento
3 years ago

  • Summary changed from why do i get error when follow wordpress/wordpress-develop github repository README.md to Docker Env: Check that Docker is running before use

@mkox
3 years ago

Added check if docker server is running

#6 @mkox
3 years ago

I added a simple run of docker info. It will fail if docker server is not running and give a hint to check it.

#7 @mkox
3 years ago

  • Keywords has-patch added; needs-patch removed

@mkox
3 years ago

Removed tmp var

#8 @hasanuzzamanshamim
3 years ago

I tested with the patch 51898.2.diff

Looks good for me to check docker info and simply throw Errors as expected.

#9 @johnbillion
3 years ago

  • Keywords needs-testing added
  • Milestone changed from Future Release to 6.1

#10 @johnbillion
3 years ago

  • Keywords needs-testing removed

#11 @desrosj
2 years ago

  • Owner set to mkox
  • Status changed from new to assigned

Assigning to @mkox to mark good first bug claimed.

#12 @desrosj
2 years ago

  • Milestone changed from 6.1 to 6.2

A committer has not yet had the chance to review and test. With 6.1 RC today, I'm going to punt this. But Build/Test Tool updates can be made at any time, so it could be moved back if someone has the chance.

This ticket was mentioned in PR #3810 on WordPress/wordpress-develop by @bgoewert.


2 years ago
#13

For me, the patch did not apply against trunk. I just added the changes manually.

bgoewert@brennans-desktop:~/Projects/WordPress/wordpress-develop$ git apply ~/Downloads/51898.2.diff
error: patch failed: tools/local-env/scripts/start.js:4
error: tools/local-env/scripts/start.js: patch does not apply

Trac ticket: https://core.trac.wordpress.org/ticket/51898

#14 @bgoewert
2 years ago

Test Report

Patch tested: PR 3810

Environment

  • OS: Pop!_OS 22.04
  • Docker Desktop v4.15.0 (Docker Engine v20.10.21)

Expected Results

Error saying "Running docker info returned an error. Is docker service and server running?"

Actual Results

I get the expected error. ✅

bgoewert@brennans-desktop:~/Projects/WordPress/wordpress-develop$ npm run env:start

> WordPress@6.2.0 env:start
> node ./tools/local-env/scripts/start.js

errors pretty printing info
/home/bgoewert/Projects/WordPress/wordpress-develop/tools/local-env/scripts/start.js:17
                throw new Error( `Running docker info returned an error. Is docker service and server running?` );
                ^

Error: Running docker info returned an error. Is docker service and server running?
    at Object.<anonymous> (/home/bgoewert/Projects/WordPress/wordpress-develop/tools/local-env/scripts/start.js:17:9)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47

Additional Notes

Before appling the patch, I was getting a different error than the reporter.

bgoewert@brennans-desktop:~/Projects/WordPress/wordpress-develop/src$ npm run env:start

> WordPress@6.2.0 env:start
> node ./tools/local-env/scripts/start.js

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
node:child_process:935
    throw err;
    ^

Error: Command failed: docker-compose up -d wordpress-develop
    at checkExecSyncError (node:child_process:861:11)
    at execSync (node:child_process:932:15)
    at Object.<anonymous> (/home/bgoewert/Projects/WordPress/wordpress-develop/tools/local-env/scripts/start.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 157954,
  stdout: null,
  stderr: null
}

And if I executed docker info (before the patch) without Docker Desktop running.

bgoewert@brennans-desktop:~/Projects/WordPress/wordpress-develop$ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.13.0)
  dev: Docker Dev Environments (Docker Inc., v0.0.5)
  extension: Manages Docker extensions (Docker Inc., v0.2.16)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.22.0)

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

#15 @robinwpdeveloper
23 months ago

Test Report

This report validates that the indicated patch addresses the issue.
Patch tested: https://core.trac.wordpress.org/attachment/ticket/51898/51898.2.diff

Environment

  • OS: macOS 11.2.3
  • Web Server: Nginx
  • PHP: 7.4.30
  • WordPress: 6.2-alpha-54642-src
  • Browser: Chrome 109.0.5414.119
  • Theme: Twenty Twenty
  • Active Plugins:
    • No Plugins activated

Actual Results

  • ✅ Issue resolved with patch.

Additional Notes

  • If the tension is to show an error message saying Docker is not running, then patch resolved the issue.
  • (Optional) I see 4 line comments in the code. Keeping only first line comment ( Check if docker server is available) is good enough.
  • I have successfully applied patch running the command: npm run grunt pathc:diff_url

Supplemental Artifacts

Before: https://d.pr/i/3SVIY6
After: https://d.pr/i/1WNTDA

This ticket was mentioned in Slack in #core by costdev. View the logs.


22 months ago

#17 follow-up: @afragen
22 months ago

Is this really something we should be checking for in core?

I've done this before and it's usually an :facepalm: moment. Then I start Docker and run the command again.

#18 in reply to: ↑ 17 @SergeyBiryukov
22 months ago

Replying to afragen:

Is this really something we should be checking for in core?

If I understand correctly, the suggested change is in the local-env scripts rather than core.

If it improves developer experience even just a bit, I don't see why not :)

#19 @afragen
22 months ago

I don’t have any issues with improving the developer experience. But this isn’t the only issue I’ve encountered when setting up wp-env. It was the easiest to solve though.

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


21 months ago

#21 @costdev
21 months ago

  • Keywords commit added

This ticket was discussed during the bug scrub. As there are two test reports, this just needs a final review and testing by a committer. Adding the commit keyword.

Additional props: @mukesh27

#22 @SergeyBiryukov
21 months ago

  • Owner changed from mkox to SergeyBiryukov
  • Status changed from assigned to accepted

#23 @SergeyBiryukov
21 months ago

It looks like the output already includes this message on Unix-type systems, even without the patch:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

But not on Windows, where the message is less clear:

'docker-compose' is not recognized as an internal or external command, operable program or batch file.

So the patch should result in a more consistent experience regardless of the platform.

#24 @SergeyBiryukov
21 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 55473:

Build/Test Tools: Check if the Docker is available when running npm run env:start.

This aims to display a more helpful error message if the Docker service is not running.

Follow-up to [45783], [45819].

Props mkox, cnspecialcolor, pento, hasanuzzamanshamim, bgoewert, robinwpdeveloper, costdev, mukesh27.
Fixes #51898.

@SergeyBiryukov commented on PR #3810:


21 months ago
#25

Thanks for the PR! Merged in r55473.

Note: See TracTickets for help on using tickets.