Skip to content

Instantly share code, notes, and snippets.

@mttchpmn
Created May 28, 2018 22:34
Show Gist options
  • Save mttchpmn/f69936fd63d2fba084ad0bba4e1ae9d2 to your computer and use it in GitHub Desktop.
Save mttchpmn/f69936fd63d2fba084ad0bba4e1ae9d2 to your computer and use it in GitHub Desktop.
Setting up Docker on Windows

Steps to get Docker (and Dev environment) working on Windows 10

Steps

  • Download docker for Windows

  • Download Hyper Terminal (optional)

  • Download VS Code (optional)

  • Enable Windows subsystem for Linux

    • Search 'Turn Windows features on or off' and enable the checkbox
  • Install Ubuntu 18.04 from Microsoft store

  • Create a code directory in your C home folder, and symlink to Ubuntu home dir

    • Note: Inside WSL, the C home folder is located at /mnt/c/Users/$USER
    cd /mnt/c/Users/$USER
    mkdir code
    ln -s /mnt/c/Users/$USER/code ~/code
  • Set $HOME and $WW_CODE_DIR variables on Win (and Ubuntu)

    • To set on Windows, go to Control Panel>System>Advanced Settings>Environment Variables
    • Docker-compose pulls this from Windows when you run docker-compose pull
    • Restart machine (needed for the Windows env variables to take effect)
    • Run set inside CMD to see a list of all Windows env variables
  • Add this block to Ubuntu .bashrc

    • This aliases the docker command inside Ubuntu to actually use the Windows executable
    export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
    export PATH="$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin"
    alias docker=docker.exe
    alias docker-compose=docker-compose.exe
  • Install git and clone docker, helperscripts into code (You can do this from WSL)

  • In CMD, cd to docker dir and docker-compose pull

    • Doesn't look like 'pull' works in subsys, though 'compose up' does work -EDIT: maybe it does. Fuck I dunno. Give it a whirl.
  • Remove the the .../bash_history:/home/wherewolf/.bash_history lines from docker-compose.yml

    • (causes docker to throw an error about inability to mount a file to a dir otherwise)
  • mkdir .ssh and add keys and config in both Windows and Ubuntu home dirs

    • IMPORTANT - I think I fucked this up a few times so double check you have correct perms and everything on the files and folder
    • .ssh folder does need to exist in Windows home, so that docker-compose can copy the folder into the container, then the Ubuntu .ssh folder will be used when you ssh into the docker container from Ubuntu

Notes

  • Doesn't look like the 'expose docker port on tcp (non-tls)' needs to be ticked
  • Not sure about the 'shared drives' setting in Docker (it is ticked on my setup though)
  • docker-compose up is fine to call from Ubuntu subsys

Gotchas

  • If Docker throws the error on 'docker-compose up' bitching about input/ output, it's likely that the containers got force killed
    • Restart Docker and you should be good to go
  • docker exec -it /bin/bash will not work from inside ubuntu subsystem - it needs to be called from native (cmd/ git bash etc)
  • docker login I think doesn't work from subsys, needs to be called from native (cmd / git bash etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment