A quick guide on how to setup X11 forwarding on macOS when using docker containers requiring a DISPLAY.
This guide was tested on:
- macOS Catalina 10.15.4
- docker desktop 2.2.0.5 (43884) - stable release
- XQuartz 2.7.11 (xorg-server 1.18.4)
| # 0. ON WINDOWS : | |
| # On windows, to check which WSL you use, type ` wsl --list --verbose ` in admin cmd. | |
| # If you are not in WSL2, reinstall the machine with WSL2 : https://docs.microsoft.com/fr-fr/windows/wsl/install-win10 | |
| # 1. Make sure you are running with systemd | |
| # sudo systemctl must not say "Failed to connect to bus" | |
| # If so, I recommand you to reinstall the VM. You can try this repo too : https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git | |
| # 2. On WSL2 machine | |
| # /!\ Create an user with A PASSWORD and with sudo access |
| """ | |
| run python web.rewrite.example.py | |
| and then open a browser to localhost:8080/data/foo/bar | |
| The two segments of the path below /data are transformed into query | |
| arguments using the rewrite function pathToArgs. | |
| The root resource is wrapped with the rewrite resource | |
| The second arg to RewriterResource is the rewrite function. |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| var childNode = document.createElement('p'); | |
| childNode.innerHTML = '这里是提示信息〜〜'; | |
| //childNode.setAttribute('class', 'alerts'); | |
| //childNode.setAttribute('onclick', 'this.style.display = "none"'); | |
| childNode.className = 'alerts'; | |
| childNode.onclick = function () { | |
| this.style.display = 'none'; | |
| } | |
| document.getElementsByTagName('body')[0].appendChild(childNode); |
| export default { | |
| name: 'PageForum', | |
| data() { | |
| return { | |
| } | |
| }, | |
| mounted() { | |
| // write initial code here when DOM is loaded | |
| }, |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width,initial-scale=1.0" /> | |
| <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
| <title>Vue App</title> | |
| </head> |
| # https://stackoverflow.com/questions/10395319/python-convert-str-to-javascript-literal-string | |
| import json | |
| jsstring = """ | |
| foo "bar" | |
| """ | |
| print 'function dosomething () { return %s.toLowerCase(); }' % json.dumps(jsstring) |
| // https://stackoverflow.com/questions/22503908/html-is-img-src-scriptsome-javascript-script-allowed | |
| // https://stackoverflow.com/questions/34467135/insert-javascript-code-inside-img-src/34467158 | |
| document.write('<img src=' + someVariable + ' alt="">'); |