docs(whitespace): standardize `CMD` example commands (#17033)

This commit is contained in:
John Bampton 2023-04-07 01:56:38 +10:00 committed by GitHub
parent 96fe0ef17a
commit b3efa5a257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -241,7 +241,7 @@ image is used to start a container.
We do this with the `CMD` command:
```dockerfile
CMD [ "/docker-gs-ping" ]
CMD ["/docker-gs-ping"]
```
Here's the complete `Dockerfile`:
@ -273,7 +273,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /docker-gs-ping
EXPOSE 8080
# Run
CMD [ "/docker-gs-ping" ]
CMD ["/docker-gs-ping"]
```
The `Dockerfile` may also contain _comments_. They always begin with a `#` symbol,

View File

@ -158,7 +158,7 @@ COPY . .
The COPY command takes all the files located in the current directory and copies them into the image. Now, all we have to do is to tell Docker what command we want to run when our image is run inside of a container. We do this with the `CMD` command.
```dockerfile
CMD [ "node", "server.js" ]
CMD ["node", "server.js"]
```
Here's the complete Dockerfile.
@ -177,7 +177,7 @@ RUN npm install --production
COPY . .
CMD [ "node", "server.js" ]
CMD ["node", "server.js"]
```
## Create a .dockerignore file

View File

@ -119,12 +119,12 @@ COPY package-lock.json package-lock.json
FROM base as test
RUN npm ci
COPY . .
CMD [ "npm", "run", "test" ]
CMD ["npm", "run", "test"]
FROM base as prod
RUN npm ci --production
COPY . .
CMD [ "node", "server.js" ]
CMD ["node", "server.js"]
```
We first add a label `as base` to the `FROM node:18-alpine` statement. This allows us to refer to this build stage in other build stages. Next we add a new build stage labeled test. We will use this stage for running our tests.
@ -189,7 +189,7 @@ RUN npm run test
FROM base as prod
RUN npm ci --production
COPY . .
CMD [ "node", "server.js" ]
CMD ["node", "server.js"]
```
Now to run our tests, we just need to run the docker build command as above.

View File

@ -116,7 +116,7 @@ COPY . .
Now, tell Docker what command to run when the image is executed inside a container using the `CMD` command. Note that you need to make the application externally visible (i.e. from outside the container) by specifying `--host=0.0.0.0`.
```dockerfile
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
CMD ["python3", "-m" , "flask", "run", "--host=0.0.0.0"]
```
Here's the complete Dockerfile.
@ -133,7 +133,7 @@ RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
CMD ["python3", "-m" , "flask", "run", "--host=0.0.0.0"]
```
### Directory structure
@ -170,7 +170,7 @@ $ docker build --tag python-docker .
=> [3/6] COPY requirements.txt requirements.txt
=> [4/6] RUN pip3 install -r requirements.txt
=> [5/6] COPY . .
=> [6/6] CMD [ "python3", "-m", "flask", "run", "--host=0.0.0.0"]
=> [6/6] CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"]
=> exporting to image
=> => exporting layers
=> => writing image sha256:8cae92a8fbd6d091ce687b71b31252056944b09760438905b726625831564c4c