Merge pull request #13370 from thaJeztah/fix_get_started_highlighting

fix code-highlighting in "get started"
This commit is contained in:
Usha Mandya 2021-08-18 10:35:44 +01:00 committed by GitHub
commit 62d0daa0e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 45 deletions

View File

@ -42,38 +42,38 @@ see a few flaws in the Dockerfile below. But, don't worry. We'll go over them.
1. Create a file named `Dockerfile` in the same folder as the file `package.json` with the following contents.
```dockerfile
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
```
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.
```dockerfile
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
```
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.
2. 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.
```console
$ docker build -t getting-started .
```
```console
$ docker build -t getting-started .
```
This command used the Dockerfile to build a new container image. You might
have noticed that a lot of "layers" were downloaded. This is because we instructed
the builder that we wanted to start from the `node:12-alpine` image. But, since we
didn't have that on our machine, that image needed to be downloaded.
This command used the Dockerfile to build a new container image. You might
have noticed that a lot of "layers" were downloaded. This is because we instructed
the builder that we wanted to start from the `node:12-alpine` image. But, since we
didn't have that on our machine, that image needed to be downloaded.
After the image was downloaded, we copied in our application and used `yarn` to
install our application's dependencies. The `CMD` directive specifies the default
command to run when starting a container from this image.
After the image was downloaded, we copied in our application and used `yarn` to
install our application's dependencies. The `CMD` directive specifies the default
command to run when starting a container from this image.
Finally, the `-t` flag tags our image. Think of this simply as a human-readable name
for the final image. Since we named the image `getting-started`, we can refer to that
image when we run a container.
Finally, the `-t` flag tags our image. Think of this simply as a human-readable name
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.
The `.` at the end of the `docker build` command tells that Docker should look for the `Dockerfile` in the current directory.
## Start an app container
@ -81,21 +81,21 @@ Now that we have an image, let's run the application. To do so, we will use the
command (remember that from earlier?).
1. Start your container using the `docker run` command and specify the name of the image we
just created:
just created:
```console
$ docker run -dp 3000:3000 getting-started
```
```console
$ docker run -dp 3000:3000 getting-started
```
Remember the `-d` and `-p` flags? We're running the new container in "detached" mode (in the
background) and creating a mapping between the host's port 3000 to the container's port 3000.
Without the port mapping, we wouldn't be able to access the application.
Remember the `-d` and `-p` flags? We're running the new container in "detached" mode (in the
background) and creating a mapping between the host's port 3000 to the container's port 3000.
Without the port mapping, we wouldn't be able to access the application.
2. After a few seconds, open your web browser to [http://localhost:3000](http://localhost:3000).
You should see our app.
You should see our app.
![Empty Todo List](images/todo-list-empty.png){: style="width:450px;margin-top:20px;"}
{: .text-center }
![Empty Todo List](images/todo-list-empty.png){: style="width:450px;margin-top:20px;"}
{: .text-center }
3. Go ahead and add an item or two and see that it works as you expect. You can mark items as
complete and remove items. Your frontend is successfully storing items in the backend.

View File

@ -56,8 +56,8 @@ For now, we will create the network first and attach the MySQL container at star
If you are using PowerShell then use this command.
```powershell
docker run -d `
```console
PS> docker run -d `
--network todo-app --network-alias mysql `
-v todo-mysql-data:/var/lib/mysql `
-e MYSQL_ROOT_PASSWORD=secret `
@ -80,7 +80,7 @@ For now, we will create the network first and attach the MySQL container at star
When the password prompt comes up, type in **secret**. In the MySQL shell, list the databases and verify
you see the `todos` database.
```cli
```console
mysql> SHOW DATABASES;
```
@ -194,8 +194,8 @@ With all of that explained, let's start our dev-ready container!
If you are using PowerShell then use this command.
```powershell
docker run -dp 3000:3000 `
```console
PS> docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
--network todo-app `
-e MYSQL_HOST=mysql `
@ -209,8 +209,7 @@ With all of that explained, let's start our dev-ready container!
2. If we look at the logs for the container (`docker logs <container-id>`), we should see a message indicating it's
using the mysql database.
```
# Previous log messages omitted
```console
$ nodemon src/index.js
[nodemon] 1.19.2
[nodemon] to restart at any time, enter `rs`
@ -231,7 +230,7 @@ With all of that explained, let's start our dev-ready container!
And in the mysql shell, run the following:
```plaintext
```console
mysql> select * from todo_items;
+--------------------------------------+--------------------+-----------+
| id | name | completed |

View File

@ -93,8 +93,8 @@ For Docker Desktop installation instructions, see [Install Docker Desktop on Mac
If you've already run the command to get started with the tutorial, congratulations! If not, open a command prompt or bash window, and run the command:
```cli
docker run -d -p 80:80 docker/getting-started
```console
$ docker run -d -p 80:80 docker/getting-started
```
You'll notice a few flags being used. Here's some more info on them: