Aditya
Aditya

Reputation: 2536

will the commands in Dockerfile run as follows?

docker build Dockerfile .//running it correctly.

1.) I have mentioned in the comments each command will execute as written, Is that correct working of this Dockerfile?

2.)These commands will be used to make the image when I ran docker build, so

[ec2-user@ip-xx-xx-xx-xx ~]$cd /project/p1

[ec2-user@ip-xx-xx-xx-xx p1]$ls

Dockerfile a b c d

My Dockerfile consists of following commands.

Dockerfile

node 8.1.0 //puls the image from hub

RUN mkdir -p /etc/x/y   //make directory in the host at path /etc/x/y

RUN mkdir /app     //make directory in the host at path /app

COPY . /app     //copy all the files that is 
WORKDIR /app    //cd /app; now the working directory will be /app for next commands i.e npm install.

RUN npm install

EXPOSE 3000  //what this will do?

Upvotes: 1

Views: 49

Answers (1)

Mohamed Ali JAMAOUI
Mohamed Ali JAMAOUI

Reputation: 14689

Question 1: how to run docker build?

docker build Dockerfile . # am I running it correctly.

No, you run it with docker build . and docker will automatically look for the Dockerfile in the current directory. Or you use docker build -f Path_to_the_docker_file/DockerFile where you clearly specify the path to the DockerFile.

Question 2: Fixing errors and clarifying commands

There are few mistakes in the Dockerfile, check the edited comments:

# pulls the image from dockerhub : YES 
# Needs to be preceeded with FROM  
FROM node 8.1.0 

# all directories are made inside the docker image
# make directory in the image at path /etc/x/y : YES
RUN mkdir -p /etc/x/y   
# make directory in the image at path /app : YES
RUN mkdir /app     

COPY . /app     # copy all the files that is : YES 
WORKDIR /app    # cd /app; now the working directory will be /app for next commands i.e npm install. : YES

RUN npm install

EXPOSE 3000  # what this will do? => tells all docker instances of this image to listen on port 3000. 

Upvotes: 1

Related Questions