Installing Docker virtual environment on Windows

Hello,

I’m having problems with that particular lesson: Using Docker virtual environment. I already have docker installed in my machine (Win 10 pro 64) and when I run the command I get this response in the terminal:

$ bash run-dev-env.sh
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile

This is the file:

set -euo pipefail

DOCKER_IMAGE=printbay-dev
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if ! [[ $(docker images -q ${DOCKER_IMAGE}:latest) ]]; then
    docker build --tag=${DOCKER_IMAGE}:latest ${SCRIPT_DIR}
fi

docker run --rm -it -v ${SCRIPT_DIR}:/workdir --workdir=/workdir --name=${DOCKER_IMAGE} \
    -p 8050:8050 \
    -p 8060:8060 \
    -p 8070:8070 \
    -p 8080:8080 \
    -p 27017:27018 \
    -p 35729:35729 \
    ${DOCKER_IMAGE}

As an alternative can I just run npm install in my folder and do everything from the folder and not the docker machine? I understand the convenience of using Docker, but right now is not helping me at all and is actually holding me back in progressing with the course.

Thanks,
Rodrigo.

Yes, you can use it without Docker. If you look in the Dockerfile you’ll see all the software that gets installed. The main things you’ll need are Vue CLI, MongoDB, and Node I think.

I’ll investigate your problem and get back to you ASAP

Can you try replace your run-dev-env.sh script with this:

#!/bin/bash

set -euo pipefail

function usage {
    echo "Usage: $0 [OPTIONS] [IMAGE_NAME]"
    echo ""
    echo "Options"
    echo " -h, --help         Display this message"
    echo " -c, --cached       Mount volume with 'cached' option"
    echo " -d, --delegated    Mount volume with 'delegated' option"
}

MOUNT_OPT=
DOCKER_IMAGE=printbay-dev
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

while [ "$#" -gt 0 ]; do
    case "$1" in
    "-h"|"--help")
        usage
        exit 0
        ;;
    "-c"|"--cached")
        MOUNT_OPT=:cached
        ;;
    "-d"|"--delegated")
        MOUNT_OPT=:delegated
        ;;
    *)
        DOCKER_IMAGE=$@
        break
        ;;
    esac
    shift
done

if ! [[ $(docker images -q ${DOCKER_IMAGE}:latest) ]]; then
    docker build --tag=${DOCKER_IMAGE}:latest ${ROOT_DIR}
fi

if [[ $(docker container ls -q -f name=${DOCKER_IMAGE}) ]]; then
    docker exec -it ${DOCKER_IMAGE} bash
else
    docker run --rm -it -v ${ROOT_DIR}:/workdir${MOUNT_OPT} --workdir=/workdir --name=${DOCKER_IMAGE} \
        -p 8050:8050 \
        -p 8060:8060 \
        -p 8070:8070 \
        -p 8080:8080 \
        -p 27017:27018 \
        -p 35729:35729 \
        ${DOCKER_IMAGE}
fi

Hey Anthony,

Thanks for the prompt response.

Indeed using mongo atlas I’ve been able to follow along without having the local mongo instance created by Docker, so it’s most likely that I’ll follow that route.

I will try the changes in the run-dev-env.sh file and let you know about it.

Have a nice weekend!!!

Cheers,
Rodrigo.

Hey Anthony

I have reached Lesson 4 and installed Docker and it’s running,
However i have no experience with Docker.
I have the same issues with installing the docker environment “bash run-dev-env.sh”
I have tried the original file from the printbay project and the file in this thread.
I’m using vscode and the integrated terminal powershell.
I get this error with the original file

PS C:\Courses\VueEnterprise\printbay> bash run-dev-env.sh
run-dev-env.sh: line 2: $’\r’: command not found
: invalid option name3: set: pipefail

And nothing with the file in this thread

I got the docker desktop running

Hi @sjsalomonsen sorry for this issue.

I think the problem is you are running a bash script (.sh) from Windows terminal. If you google “run bash script from windows” there are a few options given depending on your particular version.

Can you try that and let me know if it works.

Hi Anthony I have installed windows wsl and have installed a Linux distribution, Just to check if it works to run a Linux in wsl. I use windows 10 home version 20H2
I have cloned my my fork from git bash console and then ran the bash run-dev-env.sh script and it’s running but with an error i hope you can help to resolve. I have Attached two screendumps

I’m not sure what that error is. I just tried the following on Windows 10 and had no issue:

  • Install Windows Subsystem Linux v2
  • Used an Ubuntu image
  • Install Docker Desktop
  • In powershell: wsl
  • git clone [your-printbay]
  • cd printbay
  • bash run-dev-env.sh
  • Took about 20 mins to install but it now works

Can you ensure your run-dev.env.sh file is the same as the one in https://git.vuejsdevelopers.com/enterprise-vue/printbay? It was updated a few weeks ago.

Hi Anthony
Solved!! here’s the history
Yesterday:
When it went wrong, I used Suse enterprise linux as wsl distro. I uninstalled it, and installed Ubuntu.
I rechecked the WSL V2 installation an found that Windows Hypervisor platform was not checked in “Turn windows features on or off”.
Checked that Docker WSL integration used Ubuntu.

I then walked trough your recipe, and got an error, like cannot change something on the files when cloning my fork of printbay.

Today:
I went through the recipe againg without any error.
The difference yesterday the git clone command didn’t prompt for user/password which it did today.

I think the overall error was that i used Suse enterprise Linux, and i was trying to clone printbay into a folder under c:\courses instead of accepting the default folder under c:\users.
So the conclusion is don’t mess with the default’s in WSL before you are an expert.

Cheers and Happy new Year to you