我試圖做出一個Python /瓶的webapp一個dockerfile並保持運行到我讀過不能建立Dockerfile - :使用add命令不是一個目錄錯誤
的inspite基於關閉多種變化問題所述Dockerfile我目前如下:
FROM ubuntu:latest
#Update OS
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y upgrade
# Install Python
RUN apt-get install -y python-dev python-pip
# Add requirements.txt
ADD requirements.txt /webapp
ADD requirements.txt .
# Install uwsgi Python web server
RUN pip install uwsgi
# Install app requirements
RUN pip install -r requirements.txt
# Create app directory
ADD . /webapp
# Set the default directory for our environment
ENV HOME /webapp
WORKDIR /webapp
# Expose port 8000 for uwsgi
EXPOSE 8000
ENTRYPOINT ["uwsgi", "--http", "127.0.0.1:8000", "--module", "app:app", "--processes", "1", "--threads", "8"]
#ENTRYPOINT ["python"]
CMD ["app.py"]
試圖與命令sudo docker build -t imgcomparer .
運行此Dockerfile給出了錯誤:
Step 10/15 : ADD . /webapp
Error processing tar file(exit status 1): Error setting up pivot dir: mkdir /var/lib/docker/aufs/mnt/53420471c832e61b7f75ac5fc5268d64b932a4d589a8464c63bf5868f127ff04/webapp/.pivot_root981494252: not a directory
經過一番研究,我發現,把一個落後/
在路徑的末尾將工作(見this question和this one)
在這樣做(和相同的以下行)我在下面我dockerfile:
# Create app directory
ADD . /webapp/
# Set the default directory for our environment
ENV HOME /webapp/
WORKDIR /webapp/
,讓這個錯誤:
Step 10/15 : ADD . /webapp/
stat /var/lib/docker/aufs/mnt/f37b19a8d72d39cbbdfb0bae6359aee499fab0515e2415e251a50d528708bdd3/webapp/: not a directory
最後,我試着刪除有問題的線路。當我有
# Create app directory
# ADD . /webapp
# Set the default directory for our environment
ENV HOME /webapp
WORKDIR /webapp
碼頭文件成功構建!但是,勿庸置疑,試圖運行它給出了一個錯誤:
sudo docker run -t imgcomparer
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "chdir to cwd (\"/webapp\") set in config.json failed: not a directory"
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
目錄結構如下
app.py
image_data.db
README.txt
requirements.txt
Dockerfile
templates
- index.html
static/
- image.js
- main.css
img/
- camera.png
images/
- empty
菲亞特您需要創建Web應用程序目錄,像'RUN的mkdir/webapp' – user2915097
我把那馬上ADD命令之前它會給出錯誤:'mkdir:無法創建目錄'/ webapp /':文件存在' –
我認爲問題在於,您之前使用的是'ADD requirements.txt/webapp',可能會創建一個名爲'webapp '。因此,你不能把它當作目錄 – jorgeh