1

I am new to Docker.

I want to upload cv2 to a AWS lambda function, so I was following https://itnext.io/create-a-highly-scalable-image-processing-service-on-aws-lambda-and-api-gateway-in-10-minutes-7cbb2893a479

I am trying to generate a Lambda-ready Python package for OpenCV by running

docker run --rm -v $(pwd):/package tiivik/lambdazipper opencv-python

which is, I assume, supposed to create opencv-python.zip in the current working directory. So that I can upload it to the lambda layer.

But, when I run the command, downloading/pulling happens, but it does not create anything. I have tried other similar tutorials but none of them creates anything.

What's wrong with this?

I have Windows 10 Pro. So, I have Docker Desktop and I am using WSL 2

pizza
  • 584
  • 1
  • 10
  • 19
  • The command works and creates `opencv-python.zip` as expected. I tried that on linux. Thus maybe its your windows setup fault? – Marcin Mar 30 '20 at 04:10
  • @Marcin I am completely new to Docker, what do you think might be in my windows setup that causes this? – pizza Mar 30 '20 at 04:29
  • Don't know. Try running with ` -D, --debug ` flag. Maybe you can get some error or info on what's wrong. – Marcin Mar 30 '20 at 04:34

1 Answers1

1

Check first if $(pwd) is correctly interpreted by the docker command in your current Windows 10 shell session.

As seen here, from a regular CMD session, try instead:

docker run --rm -v  %cd%:/package tiivik/lambdazipper opencv-python

In a WSL2 bash session, try also

docker run --rm -v  $PWD:/package tiivik/lambdazipper opencv-python

Although read this thread: as mentioned in "Setting Up Docker for Windows and WSL to Work Flawlessly", you might need to modify your wsl.conf

sudo nano /etc/wsl.conf

# Now make it look like this and save the file when you're done:
[automount]
root = /
options = "metadata"

This is:

Advantage: you don't have to install on your Windows python3 (needed by the package.sh script). All the execution environment and its dependencies are already installed in the tiivik/lambdazipper image.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you it works with a regular CMD session. but now I have to figure out why it wont work on my WSL 2 Thankss! – pizza Mar 30 '20 at 05:55
  • Just out of curiosity, if you don't mind, can you break down the command? I am trying to learn Docker. What does each keyword mean? – pizza Mar 30 '20 at 05:58
  • @pizza No problem. I have edited the answer accordingly. – VonC Mar 30 '20 at 06:12
  • @pizza I have further edited the answer with WSL2 clues. – VonC Mar 30 '20 at 06:21
  • Thank you so much for your thorough explanation! I tried it but I still could not get the zip file created in a WSL2 session. I also downgraded it to WSL1 as the instructions you linked assume WSL1. I followed every single step, including the wsl.conf part. But, the problem persists. What do you think might be the problem? What else can I try? Also, In both commands you wrote, what do %cd%:/package and $PWD:/package mean? all I know PWD is my current working directory – pizza Mar 30 '20 at 08:14
  • @pizza %cd% is for a Windows CMD session, and represents the current folder. Check what $PWD represents in your WSL2 bash session (`echo $PWD`) – VonC Mar 30 '20 at 08:18
  • ```echo $PWD``` displays my current directory – pizza Mar 30 '20 at 08:23
  • Yeah it downloads stuff but does not create the zip file. Weird :( – pizza Mar 30 '20 at 08:31
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/210569/discussion-between-vonc-and-pizza). – VonC Mar 30 '20 at 08:32