如何获得docker容器的内容(Python / Pandas)

我正在尝试创build一个简单的Dockerfile ,在其中创build一个pandas数据框并将其写入一个csv。 csv保存在docker容器中,我想把它提取到我的本地目录。 当我尝试使用docker cp获取内容时,它说没有这样的容器。 这是我的docker文件:

 # User an official Python runtime as a parent image FROM python:2.7-slim # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app RUN pip install -r requirements.txt RUN mkdir -p results CMD ["python", "app.py"] 

这里是我的Python代码:

 import numpy as np import pandas as pd x = np.asarray([1, 2, 3]) print('The Mean of x is {}'.format(x.mean())) np.save('results/test', x) print('Testing Pandas') df = pd.DataFrame([[1, 2, 3], [4, 5, 6]]) print(df) df.to_csv('results/test_df.csv') 

我build立文件:

 docker build -t testing . 

然后:

 docker run testing 

当我尝试提取csv时,我无法这样做。 我真的很感激任何帮助或意见。