Yuday
Yuday

Reputation: 4489

How to build dockerfile

I have made images ubuntu 14:04 on dockerfile

I am running the syntax

  $ sudo docker build -t mypostgres .

but I am still confused as to build the dockerfile how to build it?

Upvotes: 19

Views: 96509

Answers (2)

Rafiq
Rafiq

Reputation: 11445

You can build a docker file direct from git repository or from a director.

to build a docker file first create a docker file inside your project and name it just Docker without any extension. Now inside that file write necessary command for building an image. For example

FROM node:alpine

WORKDIR /app
COPY package.json ./
RUN npm install

COPY ./ ./

CMD ["npm", "start"]

enter image description here

->Build from git: sudo docker build https://github.com/lordash/mswpw.git#fecomments:comments

in here: fecomments is branch name and comments is the folder name.

->building from git with tag and version: sudo docker build https://github.com/lordash/mswpw.git#fecomments:comments -t lordash/comments:v1.0

->Now if you want to build from a directory: first go to comments directory the run command sudo docker build .

->if you want to add tag you can use -t or -tag flag to do that: sudo docker build -t lordash . or sudo docker build -t lordash/comments .

-> Now you can version your image with the help of tag: sudo docker build -t lordash/comments:v1.0 .

->you can also apply multiple tag to an image: sudo docker build -t lordash/comments:latest -t lordash/comments:v1.0 .

Upvotes: 2

VonC
VonC

Reputation: 1323045

sudo docker build -t mypostgres . means:

  • process the file named 'Dockerfile' (default name)
  • located in the current folder (that is the final .)
  • and build as a result the image named mypostgres

So if you have a Dockerfile starting with FROM postgres, you can execute your command and have your own postgres image in no time.

Upvotes: 29

Related Questions