0

I am totally new to docker and the client I am working for have sent me dockerfile configuration .dockerignore file probably to set up the work environment.

So this is basically what he sent to me

FROM node:8

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app


COPY package.json package-lock.json ./

RUN npm install

COPY assets ./assets
COPY server ./server
COPY docs ./docs
COPY internals ./internals
COPY track ./track

RUN npm run build:dll


COPY . .

EXPOSE 3000

CMD [ "npm", "start" ]

with docker build and run command (he also provided the same)

 docker build -t reponame:tag .   
 docker run -p 3000:3000 admin-web:v1 

Here, First can someone tell me what does copy . . mean?

He asked me to configure all the ports accordingly. From going through videos, I remember that we can map ports like this -p 3000:3000 but what does configuring port means? and how can i do? any relevant article for the same would also be helpful. Do I need to make docker-compose file?

Alwaysblue
  • 9,948
  • 38
  • 121
  • 210
  • 2
    First command `RUN mkdir -p /usr/src/app` is not required as `WORKDIR` creates the directory if it does not exists. – Mike Doe Jul 20 '18 at 06:55
  • Docker has an excellent [tutorial on building and running custom images](https://docs.docker.com/get-started/part2/) which discusses a lot of this. – David Maze Jul 20 '18 at 10:19

2 Answers2

3

. is current directory in . So basicly: copy current local directory to the current container's directory.

The switch -p is used to configure port mapping. -p 2900:3000 means publish your local port 2900 to container's 3000 port so that the container is available on the outside (by your web browser for instance). Without that mapping the port would not be available to access outside the container. This port is still available to other containers inside same docker network though.

Mike Doe
  • 16,349
  • 11
  • 65
  • 88
  • Thanks Also, if you can answer second part of the question? – Alwaysblue Jul 20 '18 at 06:47
  • I read your updated answer and first thanks for answering, I understand whatever you said but what does configuring port would mean in this context? Do I need to create docker-compose file or what exactly do i need to do? By mentioning expose in our docker file and then running `docker run -p 3000:3000 admin-web:v1` he happens to be already mapping the port. What do I need to configure? – Alwaysblue Jul 20 '18 at 07:02
  • 1
    It means you can access the app through http://localhost:3000 for instance. Otherwise that port would be only available to other containers. [Docker-compose](https://docs.docker.com/compose/) is not required, but it helps you (and your team) run the container (or a group of containers) as simple as `docker-compose up` instead of `docker run -it -p 3000:3000 -v volume:mapping --other-settings [...]` – Mike Doe Jul 20 '18 at 07:16
1

You don't need to make a docker-compose.yml file, but it certainly will make your life easier if you have one, because then you can just run docker-compose up every time to run the container instead of having to run

docker run -p 3000:3000 admin-web:v1 

every time you want to start your applicaton.

Btw here is one of the ultimate docker cheatsheets that I got from a friend, might help you: https://gist.github.com/ruanbekker/4e8e4ca9b82b103973eaaea4ac81aa5f

OpenBSDNinja
  • 1,037
  • 10
  • 18