mirror of https://github.com/docker/docs.git
refresh language guides (#19405)
* language guide refresh Signed-off-by: Craig Osterhout <craig.osterhout@docker.com>
This commit is contained in:
parent
3703049154
commit
8159a9d76c
|
@ -24,7 +24,7 @@ In your `docker-dotnet-sample` directory, create a file named
|
|||
`docker-dotnet-kubernetes.yaml`. Open the file in an IDE or text editor and add
|
||||
the following contents. Replace `DOCKER_USERNAME/REPO_NAME` with your Docker
|
||||
username and the name of the repository that you created in [Configure CI/CD for
|
||||
your.NET application](configure-ci-cd.md).
|
||||
your .NET application](configure-ci-cd.md).
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
|
|
|
@ -80,7 +80,7 @@ Uncomment the database instructions in the `compose.yaml` file.
|
|||
|
||||
The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines="8-33"}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
|
@ -236,7 +236,7 @@ Use Compose Watch to automatically update your running Compose services as you e
|
|||
|
||||
Open your `compose.yaml` file in an IDE or text editor and then add the Compose Watch instructions. The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines="11-14"}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
|
@ -305,7 +305,7 @@ Add a new development stage to your Dockerfile and update your `compose.yaml` fi
|
|||
|
||||
The following is the updated Dockerfile.
|
||||
|
||||
```Dockerfile
|
||||
```Dockerfile {hl_lines="10-13"}
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||
|
@ -338,7 +338,7 @@ ENTRYPOINT ["dotnet", "myWebApp.dll"]
|
|||
|
||||
The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines="5"}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
|
|
|
@ -42,7 +42,7 @@ To run your tests when building, you need to update your Dockerfile. You can cre
|
|||
|
||||
The following is the updated Dockerfile.
|
||||
|
||||
```dockerfile
|
||||
```dockerfile {hl_lines="9"}
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
|
||||
|
|
|
@ -36,19 +36,19 @@ You need to update the following items in the `compose.yaml` file:
|
|||
|
||||
The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines="7-40"}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
context: .
|
||||
ports:
|
||||
- 3000:3000
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
|
||||
POSTGRES_DB: example
|
||||
ports:
|
||||
- 3000:3000
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
@ -148,7 +148,7 @@ development, you can use one multi-stage Dockerfile for both.
|
|||
|
||||
Update your Dockerfile to the following multi-stage Dockerfile.
|
||||
|
||||
```dockerfile
|
||||
```dockerfile {hl_lines="5-26"}
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG NODE_VERSION=18.0.0
|
||||
|
@ -167,7 +167,6 @@ COPY . .
|
|||
CMD npm run dev
|
||||
|
||||
FROM base as prod
|
||||
ENV NODE_ENV production
|
||||
RUN --mount=type=bind,source=package.json,target=package.json \
|
||||
--mount=type=bind,source=package-lock.json,target=package-lock.json \
|
||||
--mount=type=cache,target=/root/.npm \
|
||||
|
@ -178,9 +177,9 @@ CMD node src/index.js
|
|||
```
|
||||
|
||||
In the Dockerfile, you first add a label `as base` to the `FROM
|
||||
node:${NODE_VERSION}-alpine` statement. This allows you to refer to this build
|
||||
stage in other build stages. Next, you add a new build stage labeled `dev` to
|
||||
install your dev dependencies and start the container using `npm run dev`.
|
||||
node:${NODE_VERSION}-alpine` statement. This lets you refer to this build stage
|
||||
in other build stages. Next, you add a new build stage labeled `dev` to install
|
||||
your development dependencies and start the container using `npm run dev`.
|
||||
Finally, you add a stage labeled `prod` that omits the dev dependencies and runs
|
||||
your application using `node src/index.js`. To learn more about multi-stage
|
||||
builds, see [Multi-stage builds](../../build/building/multi-stage.md).
|
||||
|
@ -189,8 +188,8 @@ Next, you'll need to update your Compose file to use the new stage.
|
|||
|
||||
### Update your Compose file for development
|
||||
|
||||
To run the `dev` stage with Compose, you need to update your `compose.yaml` file.
|
||||
Open your `compose.yaml` file in an IDE or text editor, and then add the
|
||||
To run the `dev` stage with Compose, you need to update your `compose.yaml`
|
||||
file. Open your `compose.yaml` file in an IDE or text editor, and then add the
|
||||
`target: dev` instruction to target the `dev` stage from your multi-stage
|
||||
Dockerfile.
|
||||
|
||||
|
@ -200,21 +199,21 @@ Lastly, publish port `9229` for debugging.
|
|||
|
||||
The following is the updated Compose file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines=[5,8,20,21]}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
context: .
|
||||
target: dev
|
||||
ports:
|
||||
- 3000:3000
|
||||
- 9229:9229
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
|
||||
POSTGRES_DB: example
|
||||
ports:
|
||||
- 3000:3000
|
||||
- 9229:9229
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
|
|
@ -79,7 +79,7 @@ To run your tests when building, you need to update your Dockerfile to add a new
|
|||
|
||||
The following is the updated Dockerfile.
|
||||
|
||||
```dockerfile
|
||||
```dockerfile {hl_lines="27-35"}
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
ARG NODE_VERSION=18.0.0
|
||||
|
@ -98,7 +98,6 @@ COPY . .
|
|||
CMD npm run dev
|
||||
|
||||
FROM base as prod
|
||||
ENV NODE_ENV production
|
||||
RUN --mount=type=bind,source=package.json,target=package.json \
|
||||
--mount=type=bind,source=package-lock.json,target=package-lock.json \
|
||||
--mount=type=cache,target=/root/.npm \
|
||||
|
|
|
@ -55,7 +55,7 @@ In the `compose.yaml` file, you need to uncomment all of the database instructio
|
|||
|
||||
The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines="7-36"}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
|
@ -157,7 +157,7 @@ Watch](../../compose/file-watch.md).
|
|||
Open your `compose.yaml` file in an IDE or text editor and then add the Compose
|
||||
Watch instructions. The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines="14-17"}
|
||||
services:
|
||||
server:
|
||||
build:
|
||||
|
|
|
@ -14,7 +14,7 @@ description: Learn how to develop your Rust application locally.
|
|||
|
||||
In this section, you’ll learn how to use volumes and networking in Docker. You’ll also use Docker to build your images and Docker Compose to make everything a whole lot easier.
|
||||
|
||||
First, you’ll take a look at running a database in a container and how you can use volumes and networking to persist your data and allow your application to talk with the database. Then you’ll pull everything together into a Compose file which allows you to set up and run a local development environment with one command.
|
||||
First, you’ll take a look at running a database in a container and how you can use volumes and networking to persist your data and let your application talk with the database. Then you’ll pull everything together into a Compose file which lets you set up and run a local development environment with one command.
|
||||
|
||||
## Run a database in a container
|
||||
|
||||
|
@ -34,7 +34,7 @@ Now create a network that your application and database will use to talk to each
|
|||
$ docker network create postgresnet
|
||||
```
|
||||
|
||||
Now you can run PostgreSQL in a container and attach to the volume and network that you created above. Docker pulls the image from Hub and runs it for you locally.
|
||||
Now you can run PostgreSQL in a container and attach to the volume and network that you created previously. Docker pulls the image from Hub and runs it for you locally.
|
||||
In the following command, option `--mount` is for starting the container with a volume. For more information, see [Docker volumes](../../storage/volumes.md).
|
||||
|
||||
```console
|
||||
|
@ -99,7 +99,7 @@ For the sample application, you'll use a variation of the backend from the react
|
|||
|
||||
`docker init` handled creating most of the instructions in the Dockerfile, but you'll need to update it for your unique application. In addition to a `src` directory, this application includes a `migrations` directory to initialize the database. Add a bind mount for the `migrations` directory to the build stage in the Dockerfile. The following is the updated Dockerfile.
|
||||
|
||||
```dockerfile
|
||||
```dockerfile {hl_lines="28"}
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# Comments are provided throughout this file to help you get started.
|
||||
|
@ -219,7 +219,7 @@ You need to update the following items in the `compose.yaml` file:
|
|||
|
||||
The following is the updated `compose.yaml` file.
|
||||
|
||||
```yaml
|
||||
```yaml {hl_lines=["17-23","30-55"]}
|
||||
# Comments are provided throughout this file to help you get started.
|
||||
# If you need more help, visit the Docker compose reference guide at
|
||||
# https://docs.docker.com/compose/compose-file/
|
||||
|
|
|
@ -75,7 +75,7 @@ ce02b3179f0f10085db9edfccd731101868f58631bdf918ca490ff6fd223a93b
|
|||
|
||||
Docker started your container in the background and printed the Container ID on the terminal.
|
||||
|
||||
Again, make sure that our container is running properly. Run the same curl command from above.
|
||||
Again, make sure that your container is running properly. Run the curl command again.
|
||||
|
||||
```console
|
||||
$ curl http://localhost:3001
|
||||
|
@ -153,7 +153,7 @@ CONTAINER ID IMAGE COMMAND CREATED
|
|||
|
||||
Notice that the container you just restarted has been started in detached mode. Also, observe the status of the container is "Up X seconds". When you restart a container, it starts with the same flags or commands that it was originally started with.
|
||||
|
||||
Now, stop and remove all of your containers and take a look at fixing the random naming issue. Stop the container you just started. Find the name of your running container and replace the name in the command below with the name of the container on your system.
|
||||
Now, stop and remove all of your containers and take a look at fixing the random naming issue. Stop the container you just started. Find the name of your running container and replace the name in the following command with the name of the container on your system.
|
||||
|
||||
```console
|
||||
$ docker stop wonderful_kalam
|
||||
|
|
Loading…
Reference in New Issue