Komandosi
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ![](https://i.imgur.com/0zls0rU.jpg) # WSL and Docker under Windows If you haven't previously done it already, uninstall `Docker Desktop on Windows` from your Windows machine. This was previously being used to provide docker daemon to subsystem containers, but since the licensing issues, it's no longer allowed to be used for free. ## Install Ubuntu subsystem for Windows * Enable Windows features for virtualization and sub-system: ![](https://i.imgur.com/qNQUJXE.png) * Download and install windows kernel update for WSL 2 https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi * Open up Microsoft Store, and search for Ubuntu. Navigate to `Ubuntu 20.04`, and install it. ![](https://i.imgur.com/xRjTnKR.png) After opening the application enter Unix username and password by choice. (do not forget it :D). afterwards, type `exit` and close the window. * Additional app we are going to download from Microsoft Store is `Windows Terminal` ![](https://i.imgur.com/wmviUG8.png) ## Setting UP WSL (Subsystem for Linux) * Open up Windows Terminal. This should be already set by default, but just in case type command `wsl --set-default-version 2`. Running the command `wsl --list --verbose` , you should see that `Ubuntu-20.04` is set to run under version 2. In case it's showing version 1, you need to migrate it, running the following command: `wsl --set-version Ubuntu-20.04 2` * Now we will login into the subsystem, by typing only the `wsl` command from Windows Shell. Type command `sudo apt-get update` to test sudo command and also update the package lists (something linux related). ### Setting up SSH keys We need to create SSH keys for the WSL machine. We can do it by generating new keys under wsl/linux or copying it from a Windows machine. Run command `ssh-keygen` and keep pressing enter for all prompts. To print out generated key, type `cat ~/.ssh/id_rsa.pub` To use existing Windows keyes, we will override them from a Windows machine. Assuming you are still in the initial folder (something like `wslusername@hostusername:/mnt/c/Users/hostusername`), run the following commands: `sudo cp .ssh/id_rsa /home/{wslusername}/.ssh/` `sudo cp .ssh/id_rsa.pub /home/{wslusername}/.ssh/` Now we will navigate to WSL home directory: `cd ~`. Crate projects folder with `mkdir projects`. then `cd projects`. we can now test SSH key with command `git clone git@git.vegaitsourcing.rs:petar.petkovic/lambda-food.git` ### Installing Docker and Docker Compose Inside WSL, run following commands: ``` sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release ``` ``` curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg ``` ``` echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ``` `sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io` `sudo usermod -aG docker $USER` Now, the command `docker run hello-world ` will fail since we don't have docker daemon running. The fastest workaround is to run command `sudo dockerd`, after daemon has completed initialization, just close that terminal. the process will keep running in background and will keep docker daemon running. We need to run this command every time inside WSL after the system is rebooted or WSL restarted. Running `docker run hello-world` again inside WSL, should work as expected. Also, it's a bit annoying inside wsl to enter sudo password every time we run sudo command, so what you could do is run `sudo visudo`, and append `{wslusername} ALL=(ALL) NOPASSWD: ALL` inside the file. CTRL+X and select Yes to save. Install docker compose with following commands: ``` sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ``` `sudo chmod +x /usr/local/bin/docker-compose` ## Working with docker Its recommended to keep all the projects in /home/{user}/projects folder, since things will work much faster if folders are not mounted from Windows file system in VSCODE, install following extensions: Remote - WSL PHP Debug and Docker. With Docker, we can do all sorts of automatization steps using Makefile. Below are examples for VSCODE Open Windows Terminal and type `wsl`, then `cd ~/projects/lambda-food/`. Type `code .` to open lambda-food project with VSCODE under WSL.Go through all extensions and install then in WSL, clicking on green icon `Install in WSL:Ubuntu...` Now, open up terminal in VSCODE. ![](https://i.imgur.com/8ke9J4a.png) Clicking on bottom left WSl icon, and then show log, will open up the WSL log. Copy and save ip address outlined above, it will be important latter when we are setting up XDEBUG Create `.vscode` folder, then create `launch.json` file inside. ``` { "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "pathMappings": { "/var/www": "${workspaceRoot}", }, "port": 9000, "log": true, "externalConsole": false, "hostname": "{WSLIP}" } ] } ``` type `code .docker/local/php/xdebug.ini` replace xdebug.client_host ip with the same `WSLIP` This file is not inside gitignore, so try not to commit this file when pushing. this is a fast workaround, working on finding more elegant solution to dynamically set this IP. Inside WSL we also need to install Make package: `sudo apt-get install make` Now, you can type `make dockerize`, and you should be able to start the project. ## Optimization Steps In windows under C:\Users\\{windowsuser} create file `.wslconfig` and paste following parameters: ``` [wsl2] memory=6GB swap=0 localhostForwarding=true ``` ## Troubleshooting ### Restarting WSL Run `wsl.exe --shutdown` inside Windows Terminal. then start it again with the `wsl` command.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully