运行此图片时我遇到了两个问题:
Dockerfile:
# cat Dockerfile
FROM ubuntu:14.04
MAINTAINER "RAGHU" <raghavendralokineni@gmail.com>
RUN apt-get update && apt-get install -y python3.4 python-pip python-dev build-essential
RUN pip install flask
COPY welcome-page/ /root/
EXPOSE 5010
CMD ["python /root/mypage_bkp/login.py", "-D", "FOREGROUND"]
root@labadmin-VirtualBox:~/RAGHU/WEBPAGE#
运行图片:
# docker run -d webpage:2.0
6f32eb7bf8c9eb41aaece84b861e33055d8ed1066805af064e65d291944fdd04
docker: Error response from daemon: oci runtime error: exec: "python /root/mypage_bkp/login.py": stat python /root/mypage_bkp/login.py: no such file or directory.
问题1:为什么显示上述错误,即使该文件存在?
使用不同的CMD运行相同的图像:
# docker run -itd webpage:2.0 /bin/bash
92950bf69de9f5696557a34eecf1d926b65a96aebdc86e529c208d4a2198534e
# docker exec -it 92950bf69de9 /bin/bash
root@92950bf69de9:/# cd /root/
root@92950bf69de9:~# ls
README.md mypage_bkp
root@92950bf69de9:~# cd mypage_bkp/
root@92950bf69de9:~/mypage_bkp# ls
database.pyc login.py names.db static templates
root@92950bf69de9:~/mypage_bkp# pwd
/root/mypage_bkp
能够以与Docker文件中提到的相同方式运行相同的应用程序:
root@92950bf69de9:~/mypage_bkp# python /root/mypage_bkp/login.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 270-194-240
问题2:我已按上述方式手动运行应用程序,无法从主机连接到容器。
我的意思是,应用程序应该可用于主机,IP地址分配给容器并暴露PORT。当我在主机上的firefox中打开IP:172.17.0.2:5010时,我看不到任何输出:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92950bf69de9 webpage:2.0 "/bin/bash" 40 minutes ago Up 40 minutes 5010/tcp cranky_jang
# docker inspect 92950bf69de9 | grep -i ipaddr
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
root@labadmin-VirtualBox:/home/labadmin# ^C
应用程序代码复制在https://github.com/Raghavendarlokineni/welcome-page/tree/master/mypage_bkp
请帮助我理解我面临的问题。