skip to Main Content

Following is my docker file content:

FROM ubuntu:18.04

MAINTAINER Amazon AI <[email protected]>


RUN apt-get -y update && apt-get install -y --no-install-recommends 
         wget 
         python3-pip 
         python3-setuptools 
         nginx 
         ca-certificates 
    && rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/pip3 /usr/bin/pip

RUN pip --no-cache-dir install numpy==1.16.2 scipy==1.2.1 scikit-learn==0.20.2 pandas flask gunicorn

ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt/program:${PATH}"

COPY decision_trees /opt/program
WORKDIR /opt/program

I built the docker image in windows power-shell with command docker build -t tree-model .

Now when I am trying to run the command:

docker run —rm -v $(pwd)/local_test/test_dir:/opt/ml tree-model train

It gives me the following error:

docker: invalid reference format.
See 'docker run --help'.

I tried following options:

  1. Instead of $(pwd)/local_test/test_dir I tried putting complete path: D:/Sample/local_test/test_dir:/opt/ml. It didn’t work
  2. Instead of $(pwd) I tried ${pwd} it didn’t work. (By the way $(pwd) prints the correct current directory, I tested it)
  3. All combination with back and forward slash. Still no success.
  4. All possible combinations with single and double quote on path. No success.

I am new to docker and never mounted a volume before. I tried other answers on stackoverflow but no success. Need help on this.

2

Answers


  1. $(pwd) is a Linux thing. On Windows, you can use %cd%, so you’d write

    docker run --rm -v %cd%/local_test/test_dir:/opt/ml tree-model train
    
    Login or Signup to reply.
  2. Are you running with git bash by any chance? If so, try giving in pure Windows format but double the backslashes. For example, I use something like C:\dkrshare:/dkrshare. Seems git bash environment rewrites the paths given but docker does not like the rewrite.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search