如何在不存在docker文件的情况下构builddocker镜像
新来的docker工人。
运行这个docker build .
这是Dockerfile
FROM gcr.io/google_appengine/python # Create a virtualenv for dependencies. This isolates these packages from # system-level packages. RUN virtualenv /env # Setting these environment variables are the same as running # source /env/bin/activate. ENV VIRTUAL_ENV /env ENV PATH /env/bin:$PATH # Copy the application's requirements.txt and run pip to install all # dependencies into the virtualenv. #ADD requirements.txt /app/requirements.txt #RUN pip install -r /app/requirements.txt # Add the application source code. ADD . /app # Run a WSGI server to serve the application. gunicorn must be declared as # a dependency in requirements.txt. CMD gunicorn -b :$PORT main:app CMD bash1 "while true; do echo hello; sleep 1;done" CMD ["sh", "while true; do echo hello; sleep 1;done"] CMD "echo" "Hello docker!"
但之后,当我运行docker ps
我看不到图像。
使用“docker运行”来创build和运行一个容器。 所有的docker构build不会造成一个图像。
要build立一个图像,你必须使用:
docker build -t username/imagename .
您必须使用-t
来标记您的图像,并从文档中给它起个名字:
-t,–tag value Name和可选的'name:tag'格式的标签(默认[])
然后你可以看到你的图像列表使用:
docker images
你正在使用docker ps
来列出容器而不是图像。
有关图像和容器的更多信息。
检查docker build上的文档 。