docker如何处理文件创build?

我的代码将mongo集合转储到本地文件夹,然后上传到s3存储桶

cmd = "mongoexport " \ "--host " + url + \ " --port " + str(port) + \ " --username " + user + \ " --password " + password + \ " --db " + db_name + \ " --collection " temp = cmd + name + " --out dump/" + name + ".json" subprocess.call(temp, shell=True) self.client.upload_file("dump/" + name + ".json", "devopsmlabbackup", "dump/" + db_name + "/" + name + "/" + str(curr_archive_count+1) + ".json") 

这个工程,当我在Windows和Ubuntu上运行应用程序,但在docker上运行失败,因为.upload_file()无法find目录。

Dockerfile:

 FROM python:2.7 # Install uWSGI RUN pip install uwsgi # Standard set up Nginx ENV NGINX_VERSION 1.9.11-1~jessie RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \ && apt-get update \ && apt-get -y install sudo \ && apt-get -y install mongodb \ && apt-get install -y ca-certificates nginx=${NGINX_VERSION} gettext-base \ && rm -rf /var/lib/apt/lists/* # forward request and error logs to docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log EXPOSE 80 443 # Finished setting up Nginx # Make NGINX run on the foreground RUN echo "daemon off;" >> /etc/nginx/nginx.conf # Remove default configuration from Nginx RUN rm /etc/nginx/conf.d/default.conf # Copy the modified Nginx conf COPY nginx.conf /etc/nginx/conf.d/ # Copy the base uWSGI ini file to enable default dynamic uwsgi process number COPY uwsgi.ini /etc/uwsgi/ # Install Supervisord RUN apt-get update && apt-get install -y supervisor \ && rm -rf /var/lib/apt/lists/* # Custom Supervisord config COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY . /deploy WORKDIR /deploy RUN pip install -r /deploy/requirements.txt CMD ["/usr/bin/supervisord"] 

改变了我如何导入mongo,它的工作。 在Dockerfile中:

 #Step 1: Import the MongoDB public key RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 #Step 2: Generate a file with the MongoDB repository url RUN echo "deb http://repo.mongodb.org/apt/ubuntu $(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list #Step 3: Refresh the local database with the packages RUN apt-get update #Step 4: Install the last stable MongoDB version and all the necessary packages on our system RUN apt-get -y install mongodb-org