简体   繁体   中英

Docker how to build an image with dockerfile in ngnix?

I want to build an image and I have already build my Dockerfile.I already have the container,but the image is difficult for me to buiold it.this is code for Dockerfile:

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

But the problem is, I tried to run it on my terminal (I am using MacBook Terminal) with this command.This code what I wrote in the 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

The document Dockerfile is in my downloads folder. Can I have there command and if it is possible, I need help to how to build a mongoDB and Backend.Then I want to connect both together. Thanky you

Why would you keep your project files in Downloads folder? It sounds like a horrible idea.

Still, assuming that both your Dockerfile and your website files are located there run the following command to build the image:

docker build -t countly_new:latest ~/Downloads

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM