Skip to content

Instantly share code, notes, and snippets.

@saniyathossain
Last active February 29, 2020 15:21
Show Gist options
  • Select an option

  • Save saniyathossain/742e94e48e361fae282de7ca5ad03332 to your computer and use it in GitHub Desktop.

Select an option

Save saniyathossain/742e94e48e361fae282de7ca5ad03332 to your computer and use it in GitHub Desktop.
VirtualBox Linux Configuration for Development with Docker

VirtualBox Linux (Ubuntu 19.10) Configuration for Development with Docker

Here are Some Notes for Setting Up Environment for Using Ubuntu (Version 19.10) Inside VirtualBox. Additionally Connecting VirtualBox Guest Operating System Environment (Ubuntu) with Host Operating System (For This Case - Microsoft Windows 10 Enterprise).

Installable Software

  • OpenSSH
  • Docker, Docker Compose

Dockerized PHP Executable

  • Check link for Reference.

  • Create a File named php at (If Doesn't Exist) - /usr/local/bin

  • Set Execution Permission to the File - sudo chmod +x php

  • Inside the File

    #!/bin/bash
    docker run --rm -i \
    -v /home/{username}:/home/{username} \
    -v $PWD:/code \
    -w /code \
    php:alpine php "$@"
    

    OR

    #!/bin/bash
    docker run --rm -i \
    -v /home/{username}/app/docker/www/php:/home/{username}/app/docker/www \
    php:alpine php "$@"
    
  • Check if PHP is Running

    php -v
    

Setting Up Proxy

  • Check link For Reference.
  • System Wide
    • GNOME Desktop Environment - From Activities Panel -> Right Panel
      • Wired Connection > Wired Settings > Network Proxy > Manual
  • apt
    • Create a file at (if doesn't exist) - /etc/apt/apt.conf
       Acquire::http::proxy "http://192.168.0.101:1234";
       Acquire::https::proxy "http://192.168.0.101:1234";
      
  • wget
    • Edit the file /etc/wgetrc for all users or for the user only with the ~/.wgetrc (create if not exists)
      • Check link For Reference.
      use_proxy=on
      http_proxy=127.0.0.1:8080
      https_proxy=127.0.0.1:8080
      
  • Docker
    • Create a systemd drop-in directory for the docker service (if doesn't exist):
      sudo mkdir -p /etc/systemd/system/docker.service.d
      
    • Create a File at (If Doesn't Exist) - /etc/systemd/system/docker.service.d/http-proxy.conf
      [Service]
      Environment="HTTP_PROXY=http://192.168.0.101:1234/" "HTTPS_PROXY=http://192.168.0.101:1234/" "NO_PROXY=localhost,127.0.0.0/8"
      
    • Flush changes
      sudo systemctl daemon-reload
      
    • Restart Docker
      sudo systemctl restart docker
      
    • Verify that the configuration has been loaded
      systemctl show --property=Environment docker
      

Setup SSH Between Host Machine and Guest Machine

  • Add New Port Forwarding Rule Under The Virtual Machine Guest OS.
    • Using Command Line (Check link For Reference)
    VBoxManage modifyvm "VM name" --natpf1 "ssh,tcp,,2200,,22"
    
    • Using GUI
      • Go To VM -> Network -> Adapter 1 -> Advanced -> Port Forwarding -> Add New -> ssh - TCP - - 2200 - 22
    • Now Run from Terminal
    ssh -p 2200 {username}@127.0.01
    
    • Provide the Password of the Guest OS User.
    • That's it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment