mirror of https://github.com/docker/docs.git
fix code-highlighting in "get started"
Indentation in some bullet-lists had one space too little, causing code-highlighting to not work. Also fixed some other minor issues. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
a6e5434600
commit
b724f2c44d
|
@ -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.
|
1. Create a file named `Dockerfile` in the same folder as the file `package.json` with the following contents.
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
FROM node:12-alpine
|
FROM node:12-alpine
|
||||||
RUN apk add --no-cache python g++ make
|
RUN apk add --no-cache python g++ make
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN yarn install --production
|
RUN yarn install --production
|
||||||
CMD ["node", "src/index.js"]
|
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.
|
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.
|
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
|
```console
|
||||||
$ docker build -t getting-started .
|
$ docker build -t getting-started .
|
||||||
```
|
```
|
||||||
|
|
||||||
This command used the Dockerfile to build a new container image. You might
|
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
|
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
|
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.
|
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
|
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
|
install our application's dependencies. The `CMD` directive specifies the default
|
||||||
command to run when starting a container from this image.
|
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
|
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
|
for the final image. Since we named the image `getting-started`, we can refer to that
|
||||||
image when we run a container.
|
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
|
## 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?).
|
command (remember that from earlier?).
|
||||||
|
|
||||||
1. Start your container using the `docker run` command and specify the name of the image we
|
1. Start your container using the `docker run` command and specify the name of the image we
|
||||||
just created:
|
just created:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ docker run -dp 3000:3000 getting-started
|
$ docker run -dp 3000:3000 getting-started
|
||||||
```
|
```
|
||||||
|
|
||||||
Remember the `-d` and `-p` flags? We're running the new container in "detached" mode (in the
|
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.
|
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.
|
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).
|
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.
|
||||||
|
|
||||||
{: style="width:450px;margin-top:20px;"}
|
{: style="width:450px;margin-top:20px;"}
|
||||||
{: .text-center }
|
{: .text-center }
|
||||||
|
|
||||||
3. Go ahead and add an item or two and see that it works as you expect. You can mark items as
|
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.
|
complete and remove items. Your frontend is successfully storing items in the backend.
|
||||||
|
|
|
@ -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.
|
If you are using PowerShell then use this command.
|
||||||
|
|
||||||
```powershell
|
```console
|
||||||
docker run -d `
|
PS> docker run -d `
|
||||||
--network todo-app --network-alias mysql `
|
--network todo-app --network-alias mysql `
|
||||||
-v todo-mysql-data:/var/lib/mysql `
|
-v todo-mysql-data:/var/lib/mysql `
|
||||||
-e MYSQL_ROOT_PASSWORD=secret `
|
-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
|
When the password prompt comes up, type in **secret**. In the MySQL shell, list the databases and verify
|
||||||
you see the `todos` database.
|
you see the `todos` database.
|
||||||
|
|
||||||
```cli
|
```console
|
||||||
mysql> SHOW DATABASES;
|
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.
|
If you are using PowerShell then use this command.
|
||||||
|
|
||||||
```powershell
|
```console
|
||||||
docker run -dp 3000:3000 `
|
PS> docker run -dp 3000:3000 `
|
||||||
-w /app -v "$(pwd):/app" `
|
-w /app -v "$(pwd):/app" `
|
||||||
--network todo-app `
|
--network todo-app `
|
||||||
-e MYSQL_HOST=mysql `
|
-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
|
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.
|
using the mysql database.
|
||||||
|
|
||||||
```
|
```console
|
||||||
# Previous log messages omitted
|
|
||||||
$ nodemon src/index.js
|
$ nodemon src/index.js
|
||||||
[nodemon] 1.19.2
|
[nodemon] 1.19.2
|
||||||
[nodemon] to restart at any time, enter `rs`
|
[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:
|
And in the mysql shell, run the following:
|
||||||
|
|
||||||
```plaintext
|
```console
|
||||||
mysql> select * from todo_items;
|
mysql> select * from todo_items;
|
||||||
+--------------------------------------+--------------------+-----------+
|
+--------------------------------------+--------------------+-----------+
|
||||||
| id | name | completed |
|
| id | name | completed |
|
||||||
|
|
|
@ -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:
|
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
|
```console
|
||||||
docker run -d -p 80:80 docker/getting-started
|
$ docker run -d -p 80:80 docker/getting-started
|
||||||
```
|
```
|
||||||
|
|
||||||
You'll notice a few flags being used. Here's some more info on them:
|
You'll notice a few flags being used. Here's some more info on them:
|
||||||
|
|
Loading…
Reference in New Issue