从 Microsoft 商店安装的 ubuntu20.04 中的 shell 脚本中出现推送错误

pushd error in shell script from ubuntu20.04 installed from Microsoft store

请注意,我已经在 Windows 机器上从微软商店安装了 ubuntu20.04。

我想在容器内执行所有操作,并希望在我的本地系统中有 zip 文件,但 pushd 正在寻找本地目录。欢迎推荐。

#!/bin/bash
RUNTIME=python3.7


SELENIUM_VER=3.141.0
CHROME_BINARY_VER=v1.0.0-55 # based on Chromium 69.0.3497.81
CHROMEDRIVER_VER=2.43       # supports Chrome v69-71

#mkdir -p out/build/chrome_headless/python/lib/$RUNTIME/site-packages
OUT_DIR=out/build/chrome_headless/python/lib/$RUNTIME/site-packages

docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME pip install selenium==$SELENIUM_VER --target $OUT_DIR
    
pushd build/chrome_headless

DRIVER_URL=https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VER/chromedriver_linux64.zip
curl -SL $DRIVER_URL >chromedriver.zip
unzip chromedriver.zip
rm chromedriver.zip

# download chrome binary
CHROME_URL=https://github.com/adieuadieu/serverless-chrome/releases/download/$CHROME_BINARY_VER/stable-headless-chromium-amazonlinux-2017-03.zip
curl -SL $CHROME_URL >headless-chromium.zip
unzip headless-chromium.zip
rm headless-chromium.zip

zip -r ../../chrome_headless.zip *

错误:

Collecting selenium==3.141.0 Downloading selenium-3.141.0-py2.py3-none-any.whl (904 kB) 904 kB 1.8 MB/s Collecting urllib3 Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB) 138 kB 5.9 MB/s Installing collected packages: urllib3, selenium Successfully installed selenium-3.141.0 urllib3-1.26.8 WARNING: You are using pip version 21.0; however, version 22.0.3 is available. You should consider upgrading via the '/var/lang/bin/python3.7 -m pip install --upgrade pip' command. ./docker-script-layer-linux.sh: line 16: pushd: build/chrome_headless: No such file or directory % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3987k 100 3987k 0 0 7250k 0 --:--:-- --:--:-- --:--:-- 7236k ./docker-script-layer-linux.sh: line 20: unzip: command not found % Total % Received % Xferd Average Speed Time
Time Time Current Dload Upload Total Spent Left Speed 100 685 100 685 0 0 1495 0 --:--:-- --:--:-- --:--:-- 1498 100 43.4M 100 43.4M 0 0 9496k 0 0:00:04 0:00:04 --:--:-- 10.3M

我正在使用下面的 dockerfile 来完成上面的任务

FROM lambci/lambda:python3.7

ENV SELENIUM_VER=3.141.0
#based on Chromium 69.0.3497.81
ENV CHROME_BINARY_VER=v1.0.0-55 
# supports Chrome v69-71
ENV CHROMEDRIVER_VER=2.43

ENV RUNTIME=python3.7
USER root
SHELL ["/bin/bash", "-c"]
RUN yum -y install zip unzip

# Directory in container for project source files
ENV OUT_DIR=/out/build/chrome_headless/python/lib/$RUNTIME/site-packages
# Install Python dependencies

RUN mkdir -p $OUT_DIR
RUN pip install selenium==$SELENIUM_VER --target $OUT_DIR



WORKDIR /out/build/chrome_headless

ENV DRIVER_URL=https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VER/chromedriver_linux64.zip
RUN curl -SL $DRIVER_URL >chromedriver.zip
RUN dir
RUN unzip chromedriver.zip
RUN rm chromedriver.zip

# download chrome binary
ENV CHROME_URL=https://github.com/adieuadieu/serverless-chrome/releases/download/$CHROME_BINARY_VER/stable-headless-chromium-amazonlinux-2017-03.zip
RUN curl -SL $CHROME_URL >headless-chromium.zip
RUN unzip headless-chromium.zip
RUN rm headless-chromium.zip
RUN zip -r chrome_headless.zip *