docker如何处理文件创建?

时间:2017-05-11 18:57:10

标签: python mongodb docker amazon-s3

我的代码将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()找不到该目录。

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"]

0 个答案:

没有答案