Clarify how to create Dockerfile and how to build

Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
This commit is contained in:
Stefan Scherer
2020-05-17 17:29:02 +02:00
parent b9fe2cd927
commit ed772263e4
3 changed files with 10 additions and 7 deletions

View File

@@ -11,7 +11,6 @@ think about how it will work for a large team, multiple developers, etc.
![Todo List Manager Screenshot](todo-list-sample.png){: style="width:50%;" }
{ .text-center }
## Getting our App
Before we can run the application, we need to get the application source code onto
@@ -35,7 +34,7 @@ Dockerfile is simply a text-based script of instructions that is used to
create a container image. If you've created Dockerfiles before, you might
see a few flaws in the Dockerfile below. But, don't worry! We'll go over them.
1. Create a file named Dockerfile with the following contents.
1. Create a file named `Dockerfile` in the same folder as the file `package.json` with the following contents.
```dockerfile
FROM node:12-alpine
@@ -45,7 +44,9 @@ see a few flaws in the Dockerfile below. But, don't worry! We'll go over them.
CMD ["node", "/app/src/index.js"]
```
1. Build the container image using the `docker build` command.
Please check that the file `Dockerfile` has no file extension like `.txt`. Some editors may append this file extension automatically and this would result in an error in the next step.
1. If you haven't already done so, open a terminal and go to the `app` directory with the `Dockerfile`. Now build the container image using the `docker build` command.
```bash
docker build -t getting-started .
@@ -64,6 +65,7 @@ see a few flaws in the Dockerfile below. But, don't worry! We'll go over them.
for the final image. Since we named the image `getting-started`, we can refer to that
image when we run a container.
The `.` at the end of the `docker build` command tells that Docker should look for the `Dockerfile` in the current directory.
## Starting an App Container