mirror of https://github.com/docker/docs.git
Merge pull request #10468 from thaJeztah/update_code_hints
Update code hints to better work with "rouge"
This commit is contained in:
commit
6870e3a90d
|
@ -90,7 +90,7 @@ The NodeJS service contains the following files:
|
|||
|
||||
`my-service/Dockerfile`
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM alpine
|
||||
COPY assets /assets
|
||||
CMD ["cp", "/assets", "/project"]
|
||||
|
@ -113,7 +113,7 @@ services:
|
|||
|
||||
`my-service/assets/Dockerfile`
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM NODE:9
|
||||
WORKDIR /app
|
||||
COPY package.json .
|
||||
|
@ -252,7 +252,7 @@ is used to interpolate the variables. Therefore, we provide a utility called
|
|||
To use the `interpolator` image, update `my-service/Dockerfile` to use the
|
||||
following Dockerfile:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM dockertemplate/interpolator:v0.1.5
|
||||
COPY assets .
|
||||
```
|
||||
|
@ -264,7 +264,7 @@ This places the interpolator image in the `/assets` folder and copies the
|
|||
folder to the target `/project` folder. If you prefer to do this manually, use
|
||||
a Dockerfile instead:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
WORKDIR /assets
|
||||
CMD ["/interpolator", "-config", "/run/configuration", "-source", "/assets", "-destination", "/project"]
|
||||
```
|
||||
|
|
|
@ -42,7 +42,7 @@ configure this app to use our SQL Server database, and then create a
|
|||
|
||||
1. Create a `Dockerfile` within your app directory and add the following content:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM microsoft/dotnet:2.1-sdk
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
|
|
@ -116,7 +116,7 @@ and `raw`.
|
|||
The default format is `inline` where each log message is embedded as a string.
|
||||
For example:
|
||||
|
||||
```none
|
||||
```json
|
||||
{
|
||||
"attrs": {
|
||||
"env1": "val1",
|
||||
|
@ -126,6 +126,8 @@ For example:
|
|||
"source": "stdout",
|
||||
"line": "my message"
|
||||
}
|
||||
```
|
||||
```json
|
||||
{
|
||||
"attrs": {
|
||||
"env1": "val1",
|
||||
|
@ -144,7 +146,7 @@ To format messages as `json` objects, set `--log-opt splunk-format=json`. The
|
|||
driver trys to parse every line as a JSON object and send it as an embedded
|
||||
object. If it cannot parse the message, it is sent `inline`. For example:
|
||||
|
||||
```none
|
||||
```json
|
||||
{
|
||||
"attrs": {
|
||||
"env1": "val1",
|
||||
|
@ -154,6 +156,8 @@ object. If it cannot parse the message, it is sent `inline`. For example:
|
|||
"source": "stdout",
|
||||
"line": "my message"
|
||||
}
|
||||
```
|
||||
```json
|
||||
{
|
||||
"attrs": {
|
||||
"env1": "val1",
|
||||
|
@ -182,7 +186,7 @@ Splunk Logging Driver allows you to configure few advanced options by specifying
|
|||
|
||||
| Environment variable name | Default value | Description |
|
||||
|:-------------------------------------------------|:--------------|:---------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `SPLUNK_LOGGING_DRIVER_POST_MESSAGES_FREQUENCY` | `5s` | If there is nothing to batch how often driver posts messages. You can think about this as the maximum time to wait for more messages to batch. |
|
||||
| `SPLUNK_LOGGING_DRIVER_POST_MESSAGES_FREQUENCY` | `5s` | If there is nothing to batch how often driver posts messages. You can think about this as the maximum time to wait for more messages to batch. |
|
||||
| `SPLUNK_LOGGING_DRIVER_POST_MESSAGES_BATCH_SIZE` | `1000` | How many messages driver should wait before sending them in one batch. |
|
||||
| `SPLUNK_LOGGING_DRIVER_BUFFER_MAX` | `10 * 1000` | If driver cannot connect to remote server, what is the maximum amount of messages it can hold in buffer for retries. |
|
||||
| `SPLUNK_LOGGING_DRIVER_CHANNEL_SIZE` | `4 * 1000` | How many pending messages can be in the channel which is used to send messages to background logger worker, which batches them. |
|
||||
|
|
|
@ -75,7 +75,7 @@ this in a few different ways.
|
|||
|
||||
Next, the Dockerfile:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM ubuntu:latest
|
||||
COPY my_first_process my_first_process
|
||||
COPY my_second_process my_second_process
|
||||
|
@ -88,35 +88,34 @@ this in a few different ways.
|
|||
the main process) then you can use bash's job control to facilitate that.
|
||||
First, the wrapper script:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# turn on bash's job control
|
||||
set -m
|
||||
|
||||
# turn on bash's job control
|
||||
set -m
|
||||
# Start the primary process and put it in the background
|
||||
./my_main_process &
|
||||
|
||||
# Start the primary process and put it in the background
|
||||
./my_main_process &
|
||||
# Start the helper process
|
||||
./my_helper_process
|
||||
|
||||
# Start the helper process
|
||||
./my_helper_process
|
||||
|
||||
# the my_helper_process might need to know how to wait on the
|
||||
# primary process to start before it does its work and returns
|
||||
# the my_helper_process might need to know how to wait on the
|
||||
# primary process to start before it does its work and returns
|
||||
|
||||
|
||||
# now we bring the primary process back into the foreground
|
||||
# and leave it there
|
||||
fg %1
|
||||
```
|
||||
|
||||
```conf
|
||||
FROM ubuntu:latest
|
||||
COPY my_main_process my_main_process
|
||||
COPY my_helper_process my_helper_process
|
||||
COPY my_wrapper_script.sh my_wrapper_script.sh
|
||||
CMD ./my_wrapper_script.sh
|
||||
```
|
||||
# now we bring the primary process back into the foreground
|
||||
# and leave it there
|
||||
fg %1
|
||||
```
|
||||
|
||||
```dockerfile
|
||||
FROM ubuntu:latest
|
||||
COPY my_main_process my_main_process
|
||||
COPY my_helper_process my_helper_process
|
||||
COPY my_wrapper_script.sh my_wrapper_script.sh
|
||||
CMD ./my_wrapper_script.sh
|
||||
```
|
||||
|
||||
- Use a process manager like `supervisord`. This is a moderately heavy-weight
|
||||
approach that requires you to package `supervisord` and its configuration in
|
||||
|
@ -127,12 +126,12 @@ this in a few different ways.
|
|||
and `my_second_process` files all exist in the same directory as your
|
||||
Dockerfile.
|
||||
|
||||
```conf
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update && apt-get install -y supervisor
|
||||
RUN mkdir -p /var/log/supervisor
|
||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY my_first_process my_first_process
|
||||
COPY my_second_process my_second_process
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
```
|
||||
```dockerfile
|
||||
FROM ubuntu:latest
|
||||
RUN apt-get update && apt-get install -y supervisor
|
||||
RUN mkdir -p /var/log/supervisor
|
||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY my_first_process my_first_process
|
||||
COPY my_second_process my_second_process
|
||||
CMD ["/usr/bin/supervisord"]
|
||||
```
|
||||
|
|
|
@ -35,12 +35,12 @@ keep image size small:
|
|||
fragments. The first creates two layers in the image, while the second
|
||||
only creates one.
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
RUN apt-get -y update
|
||||
RUN apt-get install -y python
|
||||
```
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
RUN apt-get -y update && apt-get install -y python
|
||||
```
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ run it, or tag any image with the name `scratch`. Instead, you can refer to it
|
|||
in your `Dockerfile`. For example, to create a minimal container using
|
||||
`scratch`:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM scratch
|
||||
ADD hello /
|
||||
CMD ["/hello"]
|
||||
|
|
|
@ -171,7 +171,7 @@ To request SSH access for a `RUN` command in the `Dockerfile`, define a mount wi
|
|||
|
||||
Here is an example Dockerfile using SSH in the container:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
# syntax=docker/dockerfile:experimental
|
||||
FROM alpine
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ A Docker image consists of read-only layers each of which represents a
|
|||
Dockerfile instruction. The layers are stacked and each one is a delta of the
|
||||
changes from the previous layer. Consider this `Dockerfile`:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM ubuntu:18.04
|
||||
COPY . /app
|
||||
RUN make /app
|
||||
|
@ -270,7 +270,7 @@ frequently changed:
|
|||
|
||||
A Dockerfile for a Go application could look like:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM golang:1.11-alpine AS build
|
||||
|
||||
# Install tools required for project
|
||||
|
@ -346,7 +346,7 @@ review. Adding a space before a backslash (`\`) helps as well.
|
|||
|
||||
Here’s an example from the [`buildpack-deps` image](https://github.com/docker-library/buildpack-deps):
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN apt-get update && apt-get install -y \
|
||||
bzr \
|
||||
cvs \
|
||||
|
@ -418,7 +418,7 @@ The following examples show the different acceptable formats. Explanatory commen
|
|||
> Strings with spaces must be quoted **or** the spaces must be escaped. Inner
|
||||
> quote characters (`"`), must also be escaped.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
# Set one or more individual labels
|
||||
LABEL com.example.version="0.0.1-beta"
|
||||
LABEL vendor1="ACME Incorporated"
|
||||
|
@ -432,14 +432,14 @@ to combine all labels into a single `LABEL` instruction, to prevent extra layers
|
|||
from being created. This is no longer necessary, but combining labels is still
|
||||
supported.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
# Set multiple labels on one line
|
||||
LABEL com.example.version="0.0.1-beta" com.example.release-date="2015-02-12"
|
||||
```
|
||||
|
||||
The above can also be written as:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
# Set multiple labels at once, using line-continuation characters to break long lines
|
||||
LABEL vendor=ACME\ Incorporated \
|
||||
com.example.is-beta= \
|
||||
|
@ -478,7 +478,7 @@ know there is a particular package, `foo`, that needs to be updated, use
|
|||
Always combine `RUN apt-get update` with `apt-get install` in the same `RUN`
|
||||
statement. For example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN apt-get update && apt-get install -y \
|
||||
package-bar \
|
||||
package-baz \
|
||||
|
@ -489,7 +489,7 @@ Using `apt-get update` alone in a `RUN` statement causes caching issues and
|
|||
subsequent `apt-get install` instructions fail. For example, say you have a
|
||||
Dockerfile:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM ubuntu:18.04
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y curl
|
||||
|
@ -498,7 +498,7 @@ RUN apt-get install -y curl
|
|||
After building the image, all layers are in the Docker cache. Suppose you later
|
||||
modify `apt-get install` by adding extra package:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM ubuntu:18.04
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y curl nginx
|
||||
|
@ -516,7 +516,7 @@ intervention. This technique is known as "cache busting". You can also achieve
|
|||
cache-busting by specifying a package version. This is known as version pinning,
|
||||
for example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN apt-get update && apt-get install -y \
|
||||
package-bar \
|
||||
package-baz \
|
||||
|
@ -530,7 +530,7 @@ in required packages.
|
|||
Below is a well-formed `RUN` instruction that demonstrates all the `apt-get`
|
||||
recommendations.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN apt-get update && apt-get install -y \
|
||||
aufs-tools \
|
||||
automake \
|
||||
|
@ -564,7 +564,7 @@ refreshed prior to `apt-get install`.
|
|||
|
||||
Some `RUN` commands depend on the ability to pipe the output of one command into another, using the pipe character (`|`), as in the following example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN wget -O - https://some.site | wc -l > /number
|
||||
```
|
||||
|
||||
|
@ -577,7 +577,7 @@ If you want the command to fail due to an error at any stage in the pipe,
|
|||
prepend `set -o pipefail &&` to ensure that an unexpected error prevents the
|
||||
build from inadvertently succeeding. For example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN set -o pipefail && wget -O - https://some.site | wc -l > /number
|
||||
```
|
||||
> Not all shells support the `-o pipefail` option.
|
||||
|
@ -586,7 +586,7 @@ RUN set -o pipefail && wget -O - https://some.site | wc -l > /number
|
|||
> Debian-based images, consider using the _exec_ form of `RUN` to explicitly
|
||||
> choose a shell that does support the `pipefail` option. For example:
|
||||
>
|
||||
> ```Dockerfile
|
||||
> ```dockerfile
|
||||
> RUN ["/bin/bash", "-c", "set -o pipefail && wget -O - https://some.site | wc -l > /number"]
|
||||
> ```
|
||||
|
||||
|
@ -641,7 +641,7 @@ variables specific to services you wish to containerize, such as Postgres’s
|
|||
Lastly, `ENV` can also be used to set commonly used version numbers so that
|
||||
version bumps are easier to maintain, as seen in the following example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
ENV PG_MAJOR 9.3
|
||||
ENV PG_VERSION 9.3.4
|
||||
RUN curl -SL http://example.com/postgres-$PG_VERSION.tar.xz | tar -xJC /usr/src/postgress && …
|
||||
|
@ -657,7 +657,7 @@ means that even if you unset the environment variable in a future layer, it
|
|||
still persists in this layer and its value can't be dumped. You can test this by
|
||||
creating a Dockerfile like the following, and then building it.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM alpine
|
||||
ENV ADMIN_USER="mark"
|
||||
RUN echo $ADMIN_USER > ./mark
|
||||
|
@ -678,7 +678,7 @@ good idea. Using `\` as a line continuation character for Linux Dockerfiles
|
|||
improves readability. You could also put all of the commands into a shell script
|
||||
and have the `RUN` command just run that shell script.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM alpine
|
||||
RUN export ADMIN_USER="mark" \
|
||||
&& echo $ADMIN_USER > ./mark \
|
||||
|
@ -711,7 +711,7 @@ the specifically required files change.
|
|||
|
||||
For example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
COPY requirements.txt /tmp/
|
||||
RUN pip install --requirement /tmp/requirements.txt
|
||||
COPY . /tmp/
|
||||
|
@ -726,7 +726,7 @@ delete the files you no longer need after they've been extracted and you don't
|
|||
have to add another layer in your image. For example, you should avoid doing
|
||||
things like:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
ADD http://example.com/big.tar.xz /usr/src/things/
|
||||
RUN tar -xJf /usr/src/things/big.tar.xz -C /usr/src/things
|
||||
RUN make -C /usr/src/things all
|
||||
|
@ -734,7 +734,7 @@ RUN make -C /usr/src/things all
|
|||
|
||||
And instead, do something like:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
RUN mkdir -p /usr/src/things \
|
||||
&& curl -SL http://example.com/big.tar.xz \
|
||||
| tar -xJC /usr/src/things \
|
||||
|
@ -754,7 +754,7 @@ default flags).
|
|||
|
||||
Let's start with an example of an image for the command line tool `s3cmd`:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
ENTRYPOINT ["s3cmd"]
|
||||
CMD ["--help"]
|
||||
```
|
||||
|
@ -808,7 +808,7 @@ exec "$@"
|
|||
The helper script is copied into the container and run via `ENTRYPOINT` on
|
||||
container start:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
COPY ./docker-entrypoint.sh /
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["postgres"]
|
||||
|
|
|
@ -37,7 +37,7 @@ builder pattern above:
|
|||
|
||||
**`Dockerfile.build`**:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM golang:1.7.3
|
||||
WORKDIR /go/src/github.com/alexellis/href-counter/
|
||||
COPY app.go .
|
||||
|
@ -52,7 +52,7 @@ and forget to continue the line using the `\` character, for example.
|
|||
|
||||
**`Dockerfile`**:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM alpine:latest
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
|
@ -97,7 +97,7 @@ multi-stage builds.
|
|||
|
||||
**`Dockerfile`**:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM golang:1.7.3
|
||||
WORKDIR /go/src/github.com/alexellis/href-counter/
|
||||
RUN go get -d -v golang.org/x/net/html
|
||||
|
@ -136,7 +136,7 @@ example improves the previous one by naming the stages and using the name in
|
|||
the `COPY` instruction. This means that even if the instructions in your
|
||||
Dockerfile are re-ordered later, the `COPY` doesn't break.
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM golang:1.7.3 AS builder
|
||||
WORKDIR /go/src/github.com/alexellis/href-counter/
|
||||
RUN go get -d -v golang.org/x/net/html
|
||||
|
@ -177,7 +177,7 @@ copy from a separate image, either using the local image name, a tag available
|
|||
locally or on a Docker registry, or a tag ID. The Docker client pulls the image
|
||||
if necessary and copies the artifact from there. The syntax is:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
|
||||
```
|
||||
|
||||
|
@ -185,7 +185,7 @@ COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
|
|||
|
||||
You can pick up where a previous stage left off by referring to it when using the `FROM` directive. For example:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM alpine:latest as builder
|
||||
RUN apk --no-cache add build-base
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ containerized application. To avoid this, you can:
|
|||
`curl` and `python-pip` after they are used to install the Python `requests`
|
||||
package, all in a single Dockerfile directive:
|
||||
|
||||
```shell
|
||||
```dockerfile
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends curl python-pip && \
|
||||
pip install requests && \
|
||||
|
|
|
@ -16,7 +16,7 @@ This PostgreSQL setup is for development-only purposes. Refer to the
|
|||
PostgreSQL documentation to fine-tune these settings so that it is
|
||||
suitably secure.
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
#
|
||||
# example Dockerfile for https://docs.docker.com/engine/examples/postgresql_service/
|
||||
#
|
||||
|
|
|
@ -19,7 +19,7 @@ quick access to a test container. Make the following substitutions:
|
|||
- With `RUN echo 'root:THEPASSWORDYOUCREATED' | chpasswd`, replace "THEPASSWORDYOUCREATED" with the password you've previously generated.
|
||||
- With `RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config`, use `without-password` instead of `prohibit-password` for Ubuntu 14.04.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM ubuntu:16.04
|
||||
|
||||
RUN apt-get update && apt-get install -y openssh-server
|
||||
|
|
|
@ -74,7 +74,7 @@ You can also build with content trust. Before running the `docker build` command
|
|||
you should set the environment variable `DOCKER_CONTENT_TRUST` either manually or
|
||||
in a scripted fashion. Consider the simple Dockerfile below.
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM docker/trusttest:latest
|
||||
RUN echo
|
||||
```
|
||||
|
|
|
@ -104,7 +104,7 @@ counter whenever you visit it.
|
|||
|
||||
4. Create a file called `Dockerfile` and paste this in:
|
||||
|
||||
```Dockerfile
|
||||
```dockerfile
|
||||
FROM python:3.4-alpine
|
||||
ADD . /code
|
||||
WORKDIR /code
|
||||
|
|
|
@ -8,7 +8,7 @@ hide_from_sitemap: true
|
|||
See which machine is "active" (a machine is considered active if the
|
||||
`DOCKER_HOST` environment variable points to it).
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE DRIVER STATE URL
|
||||
|
@ -20,4 +20,4 @@ tcp://203.0.113.81:2376
|
|||
|
||||
$ docker-machine active
|
||||
staging
|
||||
```
|
||||
```
|
||||
|
|
|
@ -20,11 +20,11 @@ Options:
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine config dev \
|
||||
--tlsverify \
|
||||
--tlscacert="/Users/ehazlett/.docker/machines/dev/ca.pem" \
|
||||
--tlscert="/Users/ehazlett/.docker/machines/dev/cert.pem" \
|
||||
--tlskey="/Users/ehazlett/.docker/machines/dev/key.pem" \
|
||||
-H tcp://192.168.99.103:2376
|
||||
```
|
||||
--tlsverify \
|
||||
--tlscacert="/Users/ehazlett/.docker/machines/dev/ca.pem" \
|
||||
--tlscert="/Users/ehazlett/.docker/machines/dev/cert.pem" \
|
||||
--tlskey="/Users/ehazlett/.docker/machines/dev/key.pem" \
|
||||
-H tcp://192.168.99.103:2376
|
||||
```
|
||||
|
|
|
@ -19,8 +19,9 @@ drivers](/machine/drivers/index.md).
|
|||
|
||||
Here is an example of using the `--virtualbox` driver to create a machine called `dev`.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine create --driver virtualbox dev
|
||||
|
||||
Creating CA: /home/username/.docker/machine/certs/ca.pem
|
||||
Creating client certificate: /home/username/.docker/machine/certs/cert.pem
|
||||
Image cache does not exist, creating it at /home/username/.docker/machine/cache...
|
||||
|
@ -40,8 +41,9 @@ drivers. These largely control aspects of Machine's provisioning process
|
|||
(including the creation of Docker Swarm containers) that the user may wish to
|
||||
customize.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine create
|
||||
|
||||
Docker Machine Version: 0.5.0 (45e3688)
|
||||
Usage: docker-machine create [OPTIONS] [arg...]
|
||||
|
||||
|
@ -78,7 +80,7 @@ geographical region (`--amazonec2-region us-west-1`), and so on.
|
|||
To see the provider-specific flags, simply pass a value for `--driver` when
|
||||
invoking the `create` help text.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine create --driver virtualbox --help
|
||||
Usage: docker-machine create [OPTIONS] [arg...]
|
||||
|
||||
|
@ -147,7 +149,7 @@ filesystem has been created, and so on.
|
|||
|
||||
The following is an example usage:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine create -d virtualbox \
|
||||
--engine-label foo=bar \
|
||||
--engine-label spam=eggs \
|
||||
|
@ -162,9 +164,10 @@ labels on the engine, and allows pushing / pulling from the insecure registry
|
|||
located at `registry.myco.com`. You can verify much of this by inspecting the
|
||||
output of `docker info`:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ eval $(docker-machine env foobarmachine)
|
||||
$ docker info
|
||||
|
||||
Containers: 0
|
||||
Images: 0
|
||||
Storage Driver: overlay
|
||||
|
@ -195,7 +198,7 @@ for all containers, and always use the `syslog` [log
|
|||
driver](/engine/reference/run.md#logging-drivers-log-driver) you
|
||||
could run the following create command:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine create -d virtualbox \
|
||||
--engine-opt dns=8.8.8.8 \
|
||||
--engine-opt log-driver=syslog \
|
||||
|
@ -205,11 +208,13 @@ $ docker-machine create -d virtualbox \
|
|||
Additionally, Docker Machine supports a flag, `--engine-env`, which can be used to
|
||||
specify arbitrary environment variables to be set within the engine with the syntax `--engine-env name=value`. For example, to specify that the engine should use `example.com` as the proxy server, you could run the following create command:
|
||||
|
||||
$ docker-machine create -d virtualbox \
|
||||
--engine-env HTTP_PROXY=http://example.com:8080 \
|
||||
--engine-env HTTPS_PROXY=https://example.com:8080 \
|
||||
--engine-env NO_PROXY=example2.com \
|
||||
proxbox
|
||||
```bash
|
||||
$ docker-machine create -d virtualbox \
|
||||
--engine-env HTTP_PROXY=http://example.com:8080 \
|
||||
--engine-env HTTPS_PROXY=https://example.com:8080 \
|
||||
--engine-env NO_PROXY=example2.com \
|
||||
proxbox
|
||||
```
|
||||
|
||||
## Specifying Docker Swarm options for the created machine
|
||||
|
||||
|
@ -232,7 +237,7 @@ you don't need to worry about it.
|
|||
|
||||
Example create:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine create -d virtualbox \
|
||||
--swarm \
|
||||
--swarm-master \
|
||||
|
|
|
@ -8,7 +8,7 @@ hide_from_sitemap: true
|
|||
Set environment variables to dictate that `docker` should run a command against
|
||||
a particular machine.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine env --help
|
||||
|
||||
Usage: docker-machine env [OPTIONS] [arg...]
|
||||
|
@ -30,10 +30,11 @@ Options:
|
|||
run in a subshell. Running `docker-machine env -u` prints `unset` commands
|
||||
which reverse this effect.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ env | grep DOCKER
|
||||
$ eval "$(docker-machine env dev)"
|
||||
$ env | grep DOCKER
|
||||
|
||||
DOCKER_HOST=tcp://192.168.99.101:2376
|
||||
DOCKER_CERT_PATH=/Users/nathanleclaire/.docker/machines/.client
|
||||
DOCKER_TLS_VERIFY=1
|
||||
|
@ -54,7 +55,7 @@ If you are using `fish` and the `SHELL` environment variable is correctly set to
|
|||
the path where `fish` is located, `docker-machine env name` prints out the
|
||||
values in the format which `fish` expects:
|
||||
|
||||
```none
|
||||
```fish
|
||||
set -x DOCKER_TLS_VERIFY 1;
|
||||
set -x DOCKER_CERT_PATH "/Users/nathanleclaire/.docker/machine/machines/overlay";
|
||||
set -x DOCKER_HOST tcp://192.168.99.102:2376;
|
||||
|
@ -69,8 +70,9 @@ If you are on Windows and using either PowerShell or `cmd.exe`, `docker-machine
|
|||
|
||||
For PowerShell:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine.exe env --shell powershell dev
|
||||
|
||||
$Env:DOCKER_TLS_VERIFY = "1"
|
||||
$Env:DOCKER_HOST = "tcp://192.168.99.101:2376"
|
||||
$Env:DOCKER_CERT_PATH = "C:\Users\captain\.docker\machine\machines\dev"
|
||||
|
@ -81,8 +83,9 @@ $Env:DOCKER_MACHINE_NAME = "dev"
|
|||
|
||||
For `cmd.exe`:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine.exe env --shell cmd dev
|
||||
|
||||
set DOCKER_TLS_VERIFY=1
|
||||
set DOCKER_HOST=tcp://192.168.99.101:2376
|
||||
set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
|
||||
|
@ -102,8 +105,9 @@ This is useful when using `docker-machine` with a local VM provider, such as
|
|||
`virtualbox` or `vmwarefusion`, in network environments where an HTTP proxy is
|
||||
required for internet access.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine env --no-proxy default
|
||||
|
||||
export DOCKER_TLS_VERIFY="1"
|
||||
export DOCKER_HOST="tcp://192.168.99.104:2376"
|
||||
export DOCKER_CERT_PATH="/Users/databus23/.docker/machine/certs"
|
||||
|
|
|
@ -15,8 +15,9 @@ Usage: docker-machine help _subcommand_
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine help config
|
||||
|
||||
Usage: docker-machine config [OPTIONS] [arg...]
|
||||
|
||||
Print the connection config for machine
|
||||
|
|
|
@ -32,7 +32,7 @@ In addition to the `text/template` syntax, there are some additional functions,
|
|||
|
||||
This is the default usage of `inspect`.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine inspect dev
|
||||
|
||||
{
|
||||
|
@ -55,8 +55,9 @@ For the most part, you can pick out any field from the JSON in a fairly
|
|||
straightforward manner.
|
||||
|
||||
{% raw %}
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine inspect --format='{{.Driver.IPAddress}}' dev
|
||||
|
||||
192.168.5.99
|
||||
```
|
||||
{% endraw %}
|
||||
|
@ -66,8 +67,9 @@ $ docker-machine inspect --format='{{.Driver.IPAddress}}' dev
|
|||
If you want a subset of information formatted as JSON, you can use the `json`
|
||||
function in the template.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine inspect --format='{{json .Driver}}' dev-fusion
|
||||
|
||||
{"Boot2DockerURL":"","CPUS":8,"CPUs":8,"CaCertPath":"/Users/hairyhenderson/.docker/machine/certs/ca.pem","DiskSize":20000,"IPAddress":"172.16.62.129","ISO":"/Users/hairyhenderson/.docker/machine/machines/dev-fusion/boot2docker-1.5.0-GH747.iso","MachineName":"dev-fusion","Memory":1024,"PrivateKeyPath":"/Users/hairyhenderson/.docker/machine/certs/ca-key.pem","SSHPort":22,"SSHUser":"docker","SwarmDiscovery":"","SwarmHost":"tcp://0.0.0.0:3376","SwarmMaster":false}
|
||||
```
|
||||
|
||||
|
@ -75,8 +77,9 @@ While this is usable, it's not very human-readable. For this reason, there is
|
|||
`prettyjson`:
|
||||
|
||||
{% raw %}
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine inspect --format='{{prettyjson .Driver}}' dev-fusion
|
||||
|
||||
{
|
||||
"Boot2DockerURL": "",
|
||||
"CPUS": 8,
|
||||
|
|
|
@ -7,11 +7,13 @@ hide_from_sitemap: true
|
|||
|
||||
Get the IP address of one or more machines.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ip dev
|
||||
|
||||
192.168.99.104
|
||||
|
||||
$ docker-machine ip dev dev2
|
||||
|
||||
192.168.99.104
|
||||
192.168.99.105
|
||||
```
|
||||
```
|
||||
|
|
|
@ -16,12 +16,15 @@ Description:
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE DRIVER STATE URL
|
||||
dev * virtualbox Running tcp://192.168.99.104:2376
|
||||
|
||||
$ docker-machine kill dev
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE DRIVER STATE URL
|
||||
dev * virtualbox Stopped
|
||||
```
|
||||
```
|
||||
|
|
|
@ -13,7 +13,7 @@ The notation is `machinename:/path/to/dir` for the argument; you can also supply
|
|||
|
||||
Consider the following example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ mkdir foo
|
||||
$ docker-machine ssh dev mkdir foo
|
||||
$ docker-machine mount dev:/home/docker/foo foo
|
||||
|
@ -26,7 +26,7 @@ bar
|
|||
Now you can use the directory on the machine, for mounting into containers.
|
||||
Any changes done in the local directory, is reflected in the machine too.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ eval $(docker-machine env dev)
|
||||
$ docker run -v /home/docker/foo:/tmp/foo busybox ls /tmp/foo
|
||||
bar
|
||||
|
@ -43,7 +43,7 @@ so this program ("sftp") needs to be present on the machine - but it usually is.
|
|||
To unmount the directory again, you can use the same options but the `-u` flag.
|
||||
You can also call `fuserunmount` (or `fusermount -u`) commands directly.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine mount -u dev:/home/docker/foo foo
|
||||
$ rmdir foo
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@ originally specified Swarm or Engine configuration).
|
|||
|
||||
Usage is `docker-machine provision [name]`. Multiple names may be specified.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine provision foo bar
|
||||
|
||||
Copying certs to the local machine directory...
|
||||
|
|
|
@ -23,7 +23,7 @@ Regenerate TLS certificates and update the machine with new certs.
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine regenerate-certs dev
|
||||
|
||||
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y
|
||||
|
@ -33,8 +33,9 @@ Regenerating TLS certificates
|
|||
If your certificates have expired, you'll need to regenerate the client certs
|
||||
as well using the `--client-certs` option:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine regenerate-certs --client-certs dev
|
||||
|
||||
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y
|
||||
Regenerating TLS certificates
|
||||
Regenerating local certificates
|
||||
|
|
|
@ -18,7 +18,8 @@ Restart a machine. Oftentimes this is equivalent to
|
|||
`docker-machine stop; docker-machine start`. But some cloud driver try to implement a clever restart which keeps the same
|
||||
IP address.
|
||||
|
||||
```
|
||||
```bash
|
||||
$ docker-machine restart dev
|
||||
|
||||
Waiting for VM to start...
|
||||
```
|
||||
|
|
|
@ -8,7 +8,7 @@ hide_from_sitemap: true
|
|||
Remove a machine. This removes the local reference and deletes it
|
||||
on the cloud provider or virtualization management platform.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine rm --help
|
||||
|
||||
Usage: docker-machine rm [OPTIONS] [arg...]
|
||||
|
@ -26,8 +26,9 @@ Options:
|
|||
|
||||
## Examples
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
|
||||
bar - virtualbox Running tcp://192.168.99.101:2376 v1.9.1
|
||||
baz - virtualbox Running tcp://192.168.99.103:2376 v1.9.1
|
||||
|
@ -36,12 +37,14 @@ qix - virtualbox Running tcp://192.168.99.102:2376 v1.9.
|
|||
|
||||
|
||||
$ docker-machine rm baz
|
||||
|
||||
About to remove baz
|
||||
Are you sure? (y/n): y
|
||||
Successfully removed baz
|
||||
|
||||
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
|
||||
bar - virtualbox Running tcp://192.168.99.101:2376 v1.9.1
|
||||
foo - virtualbox Running tcp://192.168.99.100:2376 v1.9.1
|
||||
|
@ -49,6 +52,7 @@ qix - virtualbox Running tcp://192.168.99.102:2376 v1.9.
|
|||
|
||||
|
||||
$ docker-machine rm bar qix
|
||||
|
||||
About to remove bar, qix
|
||||
Are you sure? (y/n): y
|
||||
Successfully removed bar
|
||||
|
@ -56,10 +60,12 @@ Successfully removed qix
|
|||
|
||||
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
|
||||
foo - virtualbox Running tcp://192.168.99.100:2376 v1.9.1
|
||||
|
||||
$ docker-machine rm -y foo
|
||||
|
||||
About to remove foo
|
||||
Successfully removed foo
|
||||
```
|
||||
|
|
|
@ -15,11 +15,13 @@ machine's case, you don't need to specify the name, just the path.
|
|||
|
||||
Consider the following example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ cat foo.txt
|
||||
cat: foo.txt: No such file or directory
|
||||
|
||||
$ docker-machine ssh dev pwd
|
||||
/home/docker
|
||||
|
||||
$ docker-machine ssh dev 'echo A file created remotely! >foo.txt'
|
||||
$ docker-machine scp dev:/home/docker/foo.txt .
|
||||
foo.txt 100% 28 0.0KB/s 00:00
|
||||
|
@ -40,7 +42,7 @@ transferring all of the files.
|
|||
When transferring directories and not just files, avoid rsync surprises
|
||||
by using trailing slashes on both the source and destination. For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ mkdir -p bar
|
||||
$ touch bar/baz
|
||||
$ docker-machine scp -r -d bar/ dev:/home/docker/bar/
|
||||
|
@ -61,7 +63,7 @@ For example, imagine you want to transfer your local directory
|
|||
container on the remote host. If the remote user is `ubuntu`, use a command like
|
||||
this:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine scp -r /Users/<username>/webapp MACHINE-NAME:/home/ubuntu/webapp
|
||||
```
|
||||
|
||||
|
@ -79,7 +81,7 @@ services:
|
|||
|
||||
And we can try it out like so:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ eval $(docker-machine env MACHINE-NAME)
|
||||
$ docker-compose run webapp
|
||||
```
|
||||
|
|
|
@ -9,8 +9,9 @@ Log into or run a command on a machine using SSH.
|
|||
|
||||
To login, just run `docker-machine ssh machinename`:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ssh dev
|
||||
|
||||
## .
|
||||
## ## ## ==
|
||||
## ## ## ## ===
|
||||
|
@ -34,7 +35,7 @@ bin/ etc/ init linuxrc opt/ root/ sbin/ tmp var/
|
|||
You can also specify commands to run remotely by appending them directly to the
|
||||
`docker-machine ssh` command, much like the regular `ssh` program works:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ssh dev free
|
||||
|
||||
total used free shared buffers
|
||||
|
@ -45,7 +46,7 @@ Swap: 1212036 0 1212036
|
|||
|
||||
Commands with flags work as well:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ssh dev df -h
|
||||
|
||||
Filesystem Size Used Available Use% Mounted on
|
||||
|
|
|
@ -17,7 +17,8 @@ Description:
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine start dev
|
||||
|
||||
Starting VM...
|
||||
```
|
|
@ -16,7 +16,8 @@ Description:
|
|||
|
||||
For example:
|
||||
|
||||
```
|
||||
```bash
|
||||
$ docker-machine status dev
|
||||
|
||||
Running
|
||||
```
|
|
@ -16,7 +16,7 @@ Description:
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine ls
|
||||
|
||||
NAME ACTIVE DRIVER STATE URL
|
||||
|
|
|
@ -15,7 +15,7 @@ example, if the machine uses boot2docker for its OS, this command downloads
|
|||
the latest boot2docker ISO and replace the machine's existing ISO with the
|
||||
latest.
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine upgrade default
|
||||
|
||||
Stopping machine to do the upgrade...
|
||||
|
|
|
@ -7,7 +7,8 @@ hide_from_sitemap: true
|
|||
|
||||
Get the URL of a host
|
||||
|
||||
```none
|
||||
```bash
|
||||
$ docker-machine url dev
|
||||
|
||||
tcp://192.168.99.109:2376
|
||||
```
|
|
@ -29,7 +29,7 @@ A Docker image is built up from a series of layers. Each layer represents an
|
|||
instruction in the image's Dockerfile. Each layer except the very last one is
|
||||
read-only. Consider the following Dockerfile:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM ubuntu:18.04
|
||||
COPY . /app
|
||||
RUN make /app
|
||||
|
@ -163,7 +163,7 @@ Docker 1.10).
|
|||
Now imagine that you have two different Dockerfiles. You use the first one to
|
||||
create an image called `acme/my-base-image:1.0`.
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM ubuntu:18.04
|
||||
COPY . /app
|
||||
```
|
||||
|
@ -171,7 +171,7 @@ COPY . /app
|
|||
The second one is based on `acme/my-base-image:1.0`, but has some additional
|
||||
layers:
|
||||
|
||||
```conf
|
||||
```dockerfile
|
||||
FROM acme/my-base-image:1.0
|
||||
CMD /app/hello.sh
|
||||
```
|
||||
|
|
|
@ -68,8 +68,9 @@ Daemon running on each node. Other discovery service backends such as
|
|||
haven't got the `swarm:latest` image on your local machine, Docker pulls it
|
||||
for you.
|
||||
|
||||
```none
|
||||
```console
|
||||
$ docker run swarm create
|
||||
|
||||
Unable to find image 'swarm:latest' locally
|
||||
latest: Pulling from swarm
|
||||
de939d6ed512: Pull complete
|
||||
|
@ -122,8 +123,9 @@ In this section, you create a swarm manager and two nodes.
|
|||
|
||||
For example:
|
||||
|
||||
```none
|
||||
```console
|
||||
$ docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-master
|
||||
|
||||
INFO[0000] Creating SSH key...
|
||||
INFO[0000] Creating VirtualBox VM...
|
||||
INFO[0005] Starting VirtualBox VM...
|
||||
|
@ -184,6 +186,7 @@ your swarm, and start an image on your swarm.
|
|||
|
||||
```bash
|
||||
$ docker info
|
||||
|
||||
Containers: 4
|
||||
Strategy: spread
|
||||
Filters: affinity, health, constraint, port, dependency
|
||||
|
@ -207,8 +210,9 @@ your swarm, and start an image on your swarm.
|
|||
|
||||
3. Check the images currently running on your swarm.
|
||||
|
||||
```none
|
||||
```console
|
||||
$ docker ps -a
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
78be991b58d1 swarm:latest "/swarm join --addr 3 minutes ago Up 2 minutes 2375/tcp swarm-agent-01/swarm-agent
|
||||
da5127e4f0f9 swarm:latest "/swarm join --addr 6 minutes ago Up 6 minutes 2375/tcp swarm-agent-00/swarm-agent
|
||||
|
@ -220,6 +224,7 @@ your swarm, and start an image on your swarm.
|
|||
|
||||
```bash
|
||||
$ docker run hello-world
|
||||
|
||||
Hello from Docker.
|
||||
This message shows that your installation appears to be working correctly.
|
||||
|
||||
|
@ -245,6 +250,7 @@ your swarm, and start an image on your swarm.
|
|||
|
||||
```bash
|
||||
$ docker ps -a
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
54a8690043dd hello-world:latest "/hello" 22 seconds ago Exited (0) 3 seconds ago swarm-agent-00/modest_goodall
|
||||
78be991b58d1 swarm:latest "/swarm join --addr 5 minutes ago Up 4 minutes 2375/tcp swarm-agent-01/swarm-agent
|
||||
|
|
Loading…
Reference in New Issue