Docker如何在ngnix中使用dockerfile构建映像?

问题描述

我想构建映像,并且已经构建了Dockerfile。我已经有了容器,但是该映像对我来说很难,这是Dockerfile的代码:

FROM nginx:alpine
COPY . /usr/share/nginx/html

但是问题是,我试图使用此命令在终端(我正在使用MacBook Terminal)上运行它。这段代码是我在终端中写的:

Build an image from a Dockerfile
tiadem_tatie@SIT-SMBP1606 ~ % docker run -p 80:80 countly_new
Unable to find image 'countly_new:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t Countly_new .  
invalid argument "Countly_new" for "-t,--tag" flag: invalid reference format: repository name must be lowercase
See 'docker build --help'.
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t COUNTLY_NEW .
invalid argument "COUNTLY_NEW" for "-t,--tag" flag: invalid reference format: repository name must be lowercase
See 'docker build --help'.
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t countlynew . 
error checking context: 'can't stat '/Users/tiadem_tatie/.Trash''.
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t <countlynew> .
zsh: no such file or directory: countlynew
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t countlynew path
unable to prepare context: path "path" not found
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t image-name path 
unable to prepare context: path "path" not found
tiadem_tatie@SIT-SMBP1606 ~ % docker build -t image-name path
unable to prepare context: path "path" not found
tiadem_tatie@SIT-SMBP1606 ~ % docker run --help

文档Dockerfile在我的下载文件夹中。我可以在那里有命令吗,如果可以的话,我需要有关如何构建mongoDB和Backend的帮助。然后,我想将两者连接在一起。 谢谢你

解决方法

为什么要将项目文件保存在Downloads文件夹中?这听起来像一个可怕的主意。

仍然,假设您的Dockerfile和网站文件都位于该位置,请运行以下命令来构建映像:

docker build -t countly_new:latest ~/Downloads

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...