mirror of https://github.com/docker/docs.git
AWS example added to Machine docs cloud provisioning topic, reorganized/streamlined topics, tested against updated driver, and documented per new/easier use of it per Jean-Laurent's fixes
split examples out into separate files (aws, digital ocean) fixes issue #3028:links to Swarm in overview, cloud topics, cloud examples fixed links and mis-spelling Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>
This commit is contained in:
parent
1c07446f5e
commit
0eb405f1d7
|
|
@ -5,7 +5,7 @@ description = "Understand concepts for Docker Machine, including drivers, base O
|
|||
keywords = ["docker, machine, amazonec2, azure, digitalocean, google, openstack, rackspace, softlayer, virtualbox, vmwarefusion, vmwarevcloudair, vmwarevsphere, exoscale"]
|
||||
[menu.main]
|
||||
parent="workw_machine"
|
||||
weight=3
|
||||
weight=-40
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,132 @@
|
|||
<!--[metadata]>
|
||||
+++
|
||||
title = "Provision AWS EC2 Instances"
|
||||
description = "Using Docker Machine to provision hosts on AWS"
|
||||
keywords = ["docker, machine, cloud, aws"]
|
||||
[menu.main]
|
||||
parent="cloud_examples"
|
||||
weight=2
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
# Amazon Web Services (AWS) EC2 example
|
||||
|
||||
Follow along with this example to create a Dockerized <a href="https://aws.amazon.com/" target="_blank"> Amazon Web Services (AWS)</a> EC2 instance (AMI).
|
||||
|
||||
### Step 1. Sign up for AWS and configure credentials
|
||||
|
||||
1. If you are not already an AWS user, sign up for <a href="https://aws.amazon.com/" target="_blank"> AWS</a> to create an account and get root access to EC2 cloud computers.
|
||||
|
||||
If you have an Amazon account, you can use it as your root user account.
|
||||
|
||||
2. Create an IAM (Identity and Access Management) administrator user, an admin group, and a key pair associated with a region.
|
||||
|
||||
From the AWS menus, select **Services** > **IAM** to get started.
|
||||
|
||||
To create machines on AWS, you must supply two parameters:
|
||||
|
||||
* an AWS Access Key ID
|
||||
|
||||
* an AWS Secret Access Key
|
||||
|
||||
See the AWS documentation on <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html" target="_blank">Setting Up with Amazon EC2</a>. Follow the steps for "Create an IAM User" and "Create a Key Pair".
|
||||
|
||||
### Step 2. Use Machine to create the instance
|
||||
|
||||
1. Optionally, create an AWS credential file.
|
||||
|
||||
You can create an `~/.aws/credentials` file to hold your AWS keys so that you don't have to type them every time you run the `docker-machine create` command. Here is an example of a credentials file.
|
||||
|
||||
[default]
|
||||
aws_access_key_id = AKID1234567890
|
||||
aws_secret_access_key = MY-SECRET-KEY
|
||||
|
||||
2. Run `docker-machine create` with the `amazonec2` driver, your keys, and a name for the new instance.
|
||||
|
||||
**Using a credentials file**
|
||||
|
||||
If you specified your keys in a credentials file, this command looks like this to create an instance called `aws-sandbox`:
|
||||
|
||||
docker-machine create --driver amazonec2 aws-sandbox
|
||||
|
||||
**Specifying keys at the command line**
|
||||
|
||||
If you don't have a credentials file, you can use the flags `--amazonec2-access-key` and `--amazonec2-secret-key` on the command line:
|
||||
|
||||
$ docker-machine create --driver amazonec2 --amazonec2-access-key AKI******* --amazonec2-secret-key 8T93C******* aws-sandbox
|
||||
|
||||
**Specifying a region**
|
||||
|
||||
By default, the driver creates new instances in region us-east-1 (North Virginia). You can specify a different region by using the `--amazonec2-region` flag. For example, this command creates a machine called "aws-01" in us-west-1 (Northern California).
|
||||
|
||||
$ docker-machine create --driver amazonec2 --amazonec2-region us-west-1 aws-01
|
||||
|
||||
3. Go to the AWS EC2 Dashboard to view the new instance.
|
||||
|
||||
Log into AWS with your IAM credentials, and navigate to your EC2 Running Instances.
|
||||
|
||||

|
||||
|
||||
**Note**: Make sure you set the region appropriately from the menu in the upper right; otherwise, you won't see the new instance. If you did not specify a region as part of `docker-machine create` (with the optional `--amazonec2-region` flag), then the region will be US East, which is the default.
|
||||
|
||||
3. At the command terminal, run `docker-machine ls`.
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
aws-sandbox * amazonec2 Running tcp://52.90.113.128:2376 v1.10.0
|
||||
default - virtualbox Running tcp://192.168.99.100:2376 v1.10.0-rc4
|
||||
docker-sandbox - digitalocean Running tcp://104.131.43.236:2376 v1.9.1
|
||||
|
||||
The new `aws-sandbox` instance is running, and it is the active host as indicated by the asterisk (*). When you create a new machine, your command shell automatically connects it. If for some reason your new machine is not the active host, you'll need to run `docker-machine env aws-sandbox`, followed by `eval $(docker-machine env aws-sandbox)` to connect to it.
|
||||
|
||||
### Step 3. Run Docker commands on the instance
|
||||
|
||||
1. Run some `docker-machine` commands to inspect the remote host. For example, `docker-machine ip <machine>` gets the host IP address and `docker-machine inspect <machine>` lists all the details.
|
||||
|
||||
$ docker-machine ip
|
||||
192.168.99.100
|
||||
|
||||
$ docker-machine inspect aws-sandbox
|
||||
{
|
||||
"ConfigVersion": 3,
|
||||
"Driver": {
|
||||
"IPAddress": "52.90.113.128",
|
||||
"MachineName": "aws-sandbox",
|
||||
"SSHUser": "ubuntu",
|
||||
"SSHPort": 22,
|
||||
...
|
||||
|
||||
2. Verify Docker Engine is installed correctly by running `docker` commands.
|
||||
|
||||
Start with something basic like `docker run hello-world`, or for a more interesting test, run a Dockerized webserver on your new remote machine.
|
||||
|
||||
In this example, the `-p` option is used to expose port 80 from the `nginx` container and make it accessible on port `8000` of the `docker-sandbox` host.
|
||||
|
||||
$ docker run -d -p 8000:80 --name webserver kitematic/hello-world-nginx
|
||||
Unable to find image 'kitematic/hello-world-nginx:latest' locally
|
||||
latest: Pulling from kitematic/hello-world-nginx
|
||||
a285d7f063ea: Pull complete
|
||||
2d7baf27389b: Pull complete
|
||||
...
|
||||
Digest: sha256:ec0ca6dcb034916784c988b4f2432716e2e92b995ac606e080c7a54b52b87066
|
||||
Status: Downloaded newer image for kitematic/hello-world-nginx:latest
|
||||
942dfb4a0eaae75bf26c9785ade4ff47ceb2ec2a152be82b9d7960e8b5777e65
|
||||
|
||||
In a web browser, go to `http://<host_ip>:8000` to bring up the webserver home page. You got the `<host_ip>` from the output of the `docker-machine ip <machine>` command you ran in a previous step. Use the port you exposed in the `docker run` command.
|
||||
|
||||

|
||||
|
||||
### Step 4. Use Machine to remove the instance
|
||||
|
||||
To remove a AMI instance and all of its containers and images, first stop the machine, then use `docker-machine rm`:
|
||||
|
||||
$ docker-machine stop aws-sandbox
|
||||
$ docker-machine rm aws-sandbox
|
||||
Do you really want to remove "docker-sandbox"? (y/n): y
|
||||
Successfully removed aws-sandbox
|
||||
## Where to go next
|
||||
|
||||
- [Understand Machine concepts](../concepts.md)
|
||||
- [Docker Machine driver reference](../drivers/index.md)
|
||||
- [Docker Machine subcommand reference](../reference/index.md)
|
||||
- [Provision a Docker Swarm cluster with Docker Machine](https://docs.docker.com/swarm/provision-with-machine/)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<!--[metadata]>
|
||||
+++
|
||||
title = "Learn by example"
|
||||
description = "Examples of cloud installs"
|
||||
keywords = ["docker, machine, amazonec2, azure, digitalocean, google, openstack, rackspace, softlayer, virtualbox, vmwarefusion, vmwarevcloudair, vmwarevsphere, exoscale"]
|
||||
[menu.main]
|
||||
parent="workw_machine"
|
||||
identifier="cloud_examples"
|
||||
weight="-50"
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
|
||||
# Learn by example
|
||||
|
||||
- [Digital Ocean Example](ocean.md)
|
||||
- [AWS Example](aws.md)
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<!--[metadata]>
|
||||
+++
|
||||
title = "Provision Digital Ocean Droplets"
|
||||
description = "Using Docker Machine to provision hosts on Digital Ocean"
|
||||
keywords = ["docker, machine, cloud, digital ocean"]
|
||||
[menu.main]
|
||||
parent="cloud_examples"
|
||||
weight=1
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
# Digital Ocean example
|
||||
|
||||
Follow along with this example to create a Dockerized <a href="https://digitalocean.com" target="_blank">Digital Ocean</a> Droplet (cloud host).
|
||||
|
||||
### Step 1. Create a Digital Ocean account
|
||||
|
||||
If you have not done so already, go to <a href="https://digitalocean.com" target="_blank">Digital Ocean</a>, create an account, and log in.
|
||||
|
||||
### Step 2. Generate a personal access token
|
||||
|
||||
To generate your access token:
|
||||
|
||||
1. Go to the Digital Ocean administrator console and click **API** in the header.
|
||||
|
||||

|
||||
|
||||
2. Click **Generate New Token** to get to the token generator.
|
||||
|
||||

|
||||
|
||||
3. Give the token a clever name (e.g. "machine"), make sure the **Write (Optional)** checkbox is checked, and click **Generate Token**.
|
||||
|
||||

|
||||
|
||||
4. Grab (copy to clipboard) the generated big long hex string and store it somewhere safe.
|
||||
|
||||

|
||||
|
||||
This is the personal access token you'll use in the next step to create your cloud server.
|
||||
|
||||
### Step 3. Use Machine to create the Droplet
|
||||
|
||||
1. Run `docker-machine create` with the `digitalocean` driver and pass your key to the `--digitalocean-access-token` flag, along with a name for the new cloud server.
|
||||
|
||||
For this example, we'll call our new Droplet "docker-sandbox".
|
||||
|
||||
$ docker-machine create --driver digitalocean --digitalocean-access-token xxxxx docker-sandbox
|
||||
Running pre-create checks...
|
||||
Creating machine...
|
||||
(docker-sandbox) OUT | Creating SSH key...
|
||||
(docker-sandbox) OUT | Creating Digital Ocean droplet...
|
||||
(docker-sandbox) OUT | Waiting for IP address to be assigned to the Droplet...
|
||||
Waiting for machine to be running, this may take a few minutes...
|
||||
Machine is running, waiting for SSH to be available...
|
||||
Detecting operating system of created instance...
|
||||
Detecting the provisioner...
|
||||
Provisioning created instance...
|
||||
Copying certs to the local machine directory...
|
||||
Copying certs to the remote machine...
|
||||
Setting Docker configuration on the remote daemon...
|
||||
To see how to connect Docker to this machine, run: docker-machine env docker-sandbox
|
||||
|
||||
When the Droplet is created, Docker generates a unique SSH key and stores it on your local system in `~/.docker/machines`. Initially, this is used to provision the host. Later, it's used under the hood to access the Droplet directly with the `docker-machine ssh` command. Docker Engine is installed on the cloud server and the daemon is configured to accept remote connections over TCP using TLS for authentication.
|
||||
|
||||
2. Go to the Digital Ocean console to view the new Droplet.
|
||||
|
||||

|
||||
|
||||
3. At the command terminal, run `docker-machine ls`.
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM
|
||||
default - virtualbox Running tcp://192.168.99.100:2376
|
||||
docker-sandbox * digitalocean Running tcp://45.55.139.48:2376
|
||||
|
||||
The new `docker-sandbox` machine is running, and it is the active host as indicated by the asterisk (*). When you create a new machine, your command shell automatically connects it. If for some reason your new machine is not the active host, you'll need to run `docker-machine env aws-sandbox`, followed by `eval $(docker-machine env docker-sandbox)` to connect to it.
|
||||
|
||||
### Step 4. Run Docker commands on the Droplet
|
||||
|
||||
1. Run some `docker-machine` commands to inspect the remote host. For example, `docker-machine ip <machine>` gets the host IP adddress and `docker-machine inspect <machine>` lists all the details.
|
||||
|
||||
$ docker-machine ip docker-sandbox
|
||||
104.131.43.236
|
||||
|
||||
$ docker-machine inspect docker-sandbox
|
||||
{
|
||||
"ConfigVersion": 3,
|
||||
"Driver": {
|
||||
"IPAddress": "104.131.43.236",
|
||||
"MachineName": "docker-sandbox",
|
||||
"SSHUser": "root",
|
||||
"SSHPort": 22,
|
||||
"SSHKeyPath": "/Users/samanthastevens/.docker/machine/machines/docker-sandbox/id_rsa",
|
||||
"StorePath": "/Users/samanthastevens/.docker/machine",
|
||||
"SwarmMaster": false,
|
||||
"SwarmHost": "tcp://0.0.0.0:3376",
|
||||
"SwarmDiscovery": "",
|
||||
...
|
||||
|
||||
2. Verify Docker Engine is installed correctly by running `docker` commands.
|
||||
|
||||
Start with something basic like `docker run hello-world`, or for a more interesting test, run a Dockerized webserver on your new remote machine.
|
||||
|
||||
In this example, the `-p` option is used to expose port 80 from the `nginx` container and make it accessible on port `8000` of the `docker-sandbox` host.
|
||||
|
||||
$ docker run -d -p 8000:80 --name webserver kitematic/hello-world-nginx
|
||||
Unable to find image 'kitematic/hello-world-nginx:latest' locally
|
||||
latest: Pulling from kitematic/hello-world-nginx
|
||||
a285d7f063ea: Pull complete
|
||||
2d7baf27389b: Pull complete
|
||||
...
|
||||
Digest: sha256:ec0ca6dcb034916784c988b4f2432716e2e92b995ac606e080c7a54b52b87066
|
||||
Status: Downloaded newer image for kitematic/hello-world-nginx:latest
|
||||
942dfb4a0eaae75bf26c9785ade4ff47ceb2ec2a152be82b9d7960e8b5777e65
|
||||
|
||||
In a web browser, go to `http://<host_ip>:8000` to bring up the webserver home page. You got the `<host_ip>` from the output of the `docker-machine ip <machine>` command you ran in a previous step. Use the port you exposed in the `docker run` command.
|
||||
|
||||

|
||||
|
||||
### Step 5. Use Machine to remove the Droplet
|
||||
|
||||
To remove a host and all of its containers and images, first stop the machine, then use `docker-machine rm`:
|
||||
|
||||
$ docker-machine stop docker-sandbox
|
||||
$ docker-machine rm docker-sandbox
|
||||
Do you really want to remove "docker-sandbox"? (y/n): y
|
||||
Successfully removed docker-sandbox
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM
|
||||
default * virtualbox Running tcp:////xxx.xxx.xx.xxx:xxxx
|
||||
|
||||
If you monitor the Digital Ocean console while you run these commands, you will see it update first to reflect that the Droplet was stopped, and then removed.
|
||||
|
||||
If you create a host with Docker Machine, but remove it through the cloud provider console, Machine will lose track of the server status. So please use the `docker-machine rm` command for hosts you create with `docker-machine --create`.
|
||||
|
||||
## Where to go next
|
||||
|
||||
- [Understand Machine concepts](../concepts.md)
|
||||
- [Docker Machine driver reference](../drivers/index.md)
|
||||
- [Docker Machine subcommand reference](../reference/index.md)
|
||||
- [Provision a Docker Swarm cluster with Docker Machine](https://docs.docker.com/swarm/provision-with-machine/)
|
||||
|
|
@ -1,21 +1,39 @@
|
|||
<!--[metadata]>
|
||||
+++
|
||||
title = "Provision hosts on a cloud provider"
|
||||
title = "Provision hosts in the cloud"
|
||||
description = "Using Docker Machine to provision hosts on cloud providers"
|
||||
keywords = ["docker, machine, amazonec2, azure, digitalocean, google, openstack, rackspace, softlayer, virtualbox, vmwarefusion, vmwarevcloudair, vmwarevsphere, exoscale"]
|
||||
[menu.main]
|
||||
parent="workw_machine"
|
||||
weight=2
|
||||
weight=-60
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
## Use Docker Machine to provision hosts on a cloud provider
|
||||
# Use Docker Machine to provision hosts on cloud providers
|
||||
|
||||
Docker Machine driver plugins are available for many cloud platforms, so you can use Machine to provision cloud hosts. When you use Docker Machine for provisioning, you create cloud hosts with Docker Engine installed on them.
|
||||
|
||||
You'll need to install and run Docker Machine, and create an account with the cloud provider.
|
||||
|
||||
Then you provide account verification, security credentials, and configuration options for the providers as flags to `docker-machine create`. The flags are unique for each cloud-specific driver. For instance, to pass a Digital Ocean access token you use the `--digitalocean-access-token` flag.
|
||||
Then you provide account verification, security credentials, and configuration options for the providers as flags to `docker-machine create`. The flags are unique for each cloud-specific driver. For instance, to pass a Digital Ocean access token you use the `--digitalocean-access-token` flag. Take a look at the examples below for Digital Ocean and AWS.
|
||||
|
||||
## Examples
|
||||
|
||||
### Digital Ocean
|
||||
|
||||
For Digital Ocean, this command creates a Droplet (cloud host) called "docker-sandbox".
|
||||
|
||||
$ docker-machine create --driver digitalocean --digitalocean-access-token xxxxx docker-sandbox
|
||||
|
||||
For a step-by-step guide on using Machine to create Docker hosts on Digital Ocean, see the [Digital Ocean Example](examples/ocean.md).
|
||||
|
||||
### Amazon Web Services (AWS)
|
||||
|
||||
For AWS EC2, this command creates an instance called "aws-sandbox":
|
||||
|
||||
$ docker-machine create --driver amazonec2 --amazonec2-access-key AKI******* --amazonec2-secret-key 8T93C******* aws-sandbox
|
||||
|
||||
For a step-by-step guide on using Machine to create Dockerized AWS instances, see the [Amazon Web Services (AWS) example](examples/aws.md).
|
||||
|
||||
## The docker-machine create command
|
||||
|
||||
|
|
@ -27,171 +45,17 @@ The `docker-machine create` command typically requires that you specify, at a mi
|
|||
|
||||
* `<machine>` - name of the host you want to create
|
||||
|
||||
See the <a href="../reference/create/" target="_blank">create</a> command in the Machine <a href="../reference/" target="_blank">command line reference</a> for more information.
|
||||
For convenience, `docker-machine` will use sensible defaults for choosing settings such as the image that the server is based on, but you override the defaults using the respective flags (e.g. `--digitalocean-image`). This is useful if, for example, you want to create a cloud server with a lot of memory and CPUs (by default `docker-machine` creates a small server).
|
||||
|
||||
## Drivers for providers
|
||||
For a full list of the flags/settings available and their defaults, see the output of `docker-machine create -h` at the command line, the <a href="../reference/create/" target="_blank">create</a> command in the Machine <a href="../reference/" target="_blank">command line reference</a>, and <a href="https://docs.docker.com/machine/drivers/os-base/" target="_blank">driver options and operating system defaults</a> in the Machine driver reference.
|
||||
|
||||
## Drivers for cloud providers
|
||||
|
||||
When you install Docker Machine, you get a set of drivers for various cloud providers (like Amazon Web Services, Digital Ocean, or Microsoft Azure) and local providers (like Oracle VirtualBox, VMWare Fusion, or Microsoft Hyper-V).
|
||||
|
||||
See <a href="../drivers/" target="_blank">Docker Machine driver reference</a> for details on the drivers, including required flags and configuration options (which vary by provider).
|
||||
|
||||
## Digital Ocean example
|
||||
|
||||
As an example, let's take a look at how to create a Dockerized <a href="https://digitalocean.com" target="_blank">Digital Ocean</a> _Droplet_ (cloud server).
|
||||
|
||||
### Step 1. Create a Digital Ocean account and log in
|
||||
|
||||
If you have not done so already, go to <a href="https://digitalocean.com" target="_blank">Digital Ocean</a>, create an account, and log in.
|
||||
|
||||
### Step 2. Generate a personal access token
|
||||
|
||||
To generate your access token:
|
||||
|
||||
1. Go to the Digital Ocean administrator console and click **API** in the header.
|
||||
|
||||

|
||||
|
||||
2. Click **Generate New Token** to get to the token generator.
|
||||
|
||||

|
||||
|
||||
3. Give the token a clever name (e.g. "machine"), make sure the **Write (Optional)** checkbox is checked, and click **Generate Token**.
|
||||
|
||||

|
||||
|
||||
4. Grab (copy to clipboard) the generated big long hex string and store it somewhere safe.
|
||||
|
||||

|
||||
|
||||
This is the personal access token you'll use in the next step to create your cloud server.
|
||||
|
||||
### Step 3. Use Machine to Create the Droplet
|
||||
|
||||
1. Run `docker-machine create` with the `digitalocean` driver and pass your key to the `--digitalocean-access-token` flag, along with a name for the new cloud server.
|
||||
|
||||
For this example, we'll call our new Droplet "docker-sandbox".
|
||||
|
||||
$ docker-machine create --driver digitalocean --digitalocean-access-token xxxxx docker-sandbox
|
||||
Running pre-create checks...
|
||||
Creating machine...
|
||||
(docker-sandbox) OUT | Creating SSH key...
|
||||
(docker-sandbox) OUT | Creating Digital Ocean droplet...
|
||||
(docker-sandbox) OUT | Waiting for IP address to be assigned to the Droplet...
|
||||
Waiting for machine to be running, this may take a few minutes...
|
||||
Machine is running, waiting for SSH to be available...
|
||||
Detecting operating system of created instance...
|
||||
Detecting the provisioner...
|
||||
Provisioning created instance...
|
||||
Copying certs to the local machine directory...
|
||||
Copying certs to the remote machine...
|
||||
Setting Docker configuration on the remote daemon...
|
||||
To see how to connect Docker to this machine, run: docker-machine env docker-sandbox
|
||||
|
||||
When the Droplet is created, Docker generates a unique SSH key and stores it on your local system in `~/.docker/machines`. Initially, this is used to provision the host. Later, it's used under the hood to access the Droplet directly with the `docker-machine ssh` command. Docker Engine is installed on the cloud server and the daemon is configured to accept remote connections over TCP using TLS for authentication.
|
||||
|
||||
2. Go to the Digital Ocean console to view the new Droplet.
|
||||
|
||||

|
||||
|
||||
3. At the command terminal, run `docker-machine ls`.
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM
|
||||
default * virtualbox Running tcp://192.168.99.100:2376
|
||||
docker-sandbox - digitalocean Running tcp://45.55.139.48:2376
|
||||
|
||||
Notice that the new cloud server is running but is not the active host. Our command shell is still connected to the default machine, which is currently the active host as indicated by the asterisk (*).
|
||||
|
||||
4. Run `docker-machine env docker-sandbox` to get the environment commands for the new remote host, then run `eval` as directed to re-configure the shell to connect to `docker-sandbox`.
|
||||
|
||||
$ docker-machine env docker-sandbox
|
||||
export DOCKER_TLS_VERIFY="1"
|
||||
export DOCKER_HOST="tcp://45.55.222.72:2376"
|
||||
export DOCKER_CERT_PATH="/Users/victoriabialas/.docker/machine/machines/docker-sandbox"
|
||||
export DOCKER_MACHINE_NAME="docker-sandbox"
|
||||
# Run this command to configure your shell:
|
||||
# eval "$(docker-machine env docker-sandbox)"
|
||||
|
||||
5. Re-run `docker-machine ls` to verify that our new server is the active machine, as indicated by the asterisk (*) in the ACTIVE column.
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM
|
||||
default - virtualbox Running tcp://192.168.99.100:2376
|
||||
docker-sandbox * digitalocean Running tcp://45.55.222.72:2376
|
||||
|
||||
6. Run some `docker-machine` commands to inspect the remote host. For example, `docker-machine ip <machine>` gets the host IP adddress and `docker-machine inspect <machine>` lists all the details.
|
||||
|
||||
$ docker-machine ip docker-sandbox
|
||||
104.131.43.236
|
||||
|
||||
$ docker-machine inspect docker-sandbox
|
||||
{
|
||||
"ConfigVersion": 3,
|
||||
"Driver": {
|
||||
"IPAddress": "104.131.43.236",
|
||||
"MachineName": "docker-sandbox",
|
||||
"SSHUser": "root",
|
||||
"SSHPort": 22,
|
||||
"SSHKeyPath": "/Users/samanthastevens/.docker/machine/machines/docker-sandbox/id_rsa",
|
||||
"StorePath": "/Users/samanthastevens/.docker/machine",
|
||||
"SwarmMaster": false,
|
||||
"SwarmHost": "tcp://0.0.0.0:3376",
|
||||
"SwarmDiscovery": "",
|
||||
...
|
||||
|
||||
7. Verify Docker Engine is installed correctly by running `docker` commands.
|
||||
|
||||
Start with something basic like `docker run hello-world`, or for a more interesting test, run a Dockerized webserver on your new remote machine.
|
||||
|
||||
In this example, the `-p` option is used to expose port 80 from the `nginx` container and make it accessible on port `8000` of the `docker-sandbox` host.
|
||||
|
||||
$ docker run -d -p 8000:80 --name webserver kitematic/hello-world-nginx
|
||||
Unable to find image 'kitematic/hello-world-nginx:latest' locally
|
||||
latest: Pulling from kitematic/hello-world-nginx
|
||||
a285d7f063ea: Pull complete
|
||||
2d7baf27389b: Pull complete
|
||||
...
|
||||
Digest: sha256:ec0ca6dcb034916784c988b4f2432716e2e92b995ac606e080c7a54b52b87066
|
||||
Status: Downloaded newer image for kitematic/hello-world-nginx:latest
|
||||
942dfb4a0eaae75bf26c9785ade4ff47ceb2ec2a152be82b9d7960e8b5777e65
|
||||
|
||||
In a web browser, go to `http://<host_ip>:8000` to bring up the webserver home page. You got the `<host_ip>` from the output of the `docker-machine ip <machine>` command you ran in a previous step. Use the port you exposed in the `docker run` command.
|
||||
|
||||

|
||||
|
||||
#### Understand the defaults and options on the create command
|
||||
|
||||
For convenience, `docker-machine` will use sensible defaults for choosing settings such as the image that the server is based on, but you override the defaults using the respective flags (e.g. `--digitalocean-image`). This is useful if, for example, you want to create a cloud server with a lot of memory and CPUs (by default `docker-machine` creates a small server). For a full list of the flags/settings available and their defaults, see the output of `docker-machine create -h` at the command line. See also <a href="https://docs.docker.com/machine/drivers/os-base/" target="_blank">Driver options and operating system defaults</a> and information about the <a href="https://docs.docker.com/machine/reference/create/" target="_blank">create</a> command in the Docker Machine documentation.
|
||||
|
||||
|
||||
### Step 4. Use Machine to remove the Droplet
|
||||
|
||||
To remove a host and all of its containers and images, first stop the machine, then use `docker-machine rm`:
|
||||
|
||||
$ docker-machine stop docker-sandbox
|
||||
$ docker-machine rm docker-sandbox
|
||||
Do you really want to remove "docker-sandbox"? (y/n): y
|
||||
Successfully removed docker-sandbox
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM
|
||||
default * virtualbox Running tcp:////xxx.xxx.xx.xxx:xxxx
|
||||
|
||||
If you monitor the Digital Ocean console while you run these commands, you will see it update first to reflect that the Droplet was stopped, and then removed.
|
||||
|
||||
If you create a host with Docker Machine, but remove it through the cloud provider console, Machine will lose track of the server status. So please use the `docker-machine rm` command for hosts you create with `docker-machine --create`.
|
||||
|
||||
|
||||
### Docker supported drivers
|
||||
|
||||
Docker Machine drivers are available for several other cloud providers. For a full list, see <a href="https://docs.docker.com/machine/drivers/" target="_blank">Supported Drivers</a>.
|
||||
|
||||
### Docker Machine command and driver reference
|
||||
|
||||
- `docker-machine` <a href="https://docs.docker.com/machine/reference/create/" target="_blank">create</a> command
|
||||
- <a href="https://docs.docker.com/machine/drivers/os-base/" target="_blank">Driver options and operating system defaults</a>
|
||||
|
||||
### 3rd-party driver plugins
|
||||
## 3rd-party driver plugins
|
||||
|
||||
Several Docker Machine driver plugins for use with other cloud platforms are available from 3rd party contributors. These are use-at-your-own-risk plugins, not maintained by or formally associated with Docker.
|
||||
|
||||
|
|
@ -208,15 +72,16 @@ You can add a host to Docker which only has a URL and no driver. Then you can us
|
|||
|
||||
## Using Machine to provision Docker Swarm clusters
|
||||
|
||||
Docker Machine can also provision <a href="https://docs.docker.com/swarm/" target="_blank">Docker Swarm</a> clusters. This can be used with any driver and will be secured with TLS.
|
||||
Docker Machine can also provision <a href="https://docs.docker.com/swarm/overview/" target="_blank">Docker Swarm</a> clusters. This can be used with any driver and will be secured with TLS.
|
||||
|
||||
* To get started with Swarm, see <a href="https://docs.docker.com/swarm/machine-provisioning/how-to-get-swarm/" target="_blank">Get and run the Swarm software</a>.
|
||||
* To get started with Swarm, see <a href="https://docs.docker.com/swarm/get-swarm/" target="_blank">How to get Docker Swarm</a>.
|
||||
|
||||
* To learn how to use Machine to provision a Swarm cluster, see <a href="https://docs.docker.com/swarm/machine-provisioning/provision-w-machine/" target="_blank">Provision a Swarm cluster with Docker Machine</a>.
|
||||
* To learn how to use Machine to provision a Swarm cluster, see <a href="https://docs.docker.com/swarm/provision-with-machine/" target="_blank">Provision a Swarm cluster with Docker Machine</a>.
|
||||
|
||||
## Where to go next
|
||||
|
||||
- Example: Provision Dockerized [Digital Ocean Droplets](examples/ocean.md)
|
||||
- Example: Provision Dockerized [AWS EC2 Instances](examples/aws.md)
|
||||
- [Understand Machine concepts](concepts.md)
|
||||
- <a href="../drivers/" target="_blank">Docker Machine driver reference</a>
|
||||
- <a href="../reference/" target="_blank">Docker Machine subcommand reference</a>
|
||||
- <a href="https://docs.docker.com/swarm/machine-provisioning/provision-w-machine/" target="_blank">Provision a Docker Swarm cluster with Docker Machine</a>
|
||||
- [Docker Machine driver reference](drivers/index.md)
|
||||
- [Docker Machine subcommand reference](reference/index.md)
|
||||
- [Provision a Docker Swarm cluster with Docker Machine](https://docs.docker.com/swarm/provision-with-machine/)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ description = "Get started with Docker Machine and a local VM"
|
|||
keywords = ["docker, machine, virtualbox, local"]
|
||||
[menu.main]
|
||||
parent="workw_machine"
|
||||
weight=1
|
||||
weight=-70
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
|
|
@ -213,5 +213,5 @@ For machines other than `default`, and commands other than those listed above, y
|
|||
|
||||
- Provision multiple Docker hosts [on your cloud provider](get-started-cloud.md)
|
||||
- [Understand Machine concepts](concepts.md)
|
||||
- <a href="https://docs.docker.com/machine/drivers/" target="_blank">Docker Machine driver reference</a>
|
||||
- <a href="https://docs.docker.com/machine/drivers/index.md" target="_blank">Docker Machine driver reference</a>
|
||||
- <a href="https://docs.docker.com/machine/reference/" target="_blank">Docker Machine subcommand reference</a>
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 348 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 311 KiB |
|
|
@ -15,6 +15,8 @@ identifier="workw_machine"
|
|||
- [Install Docker Machine](install-machine.md)
|
||||
- Install a machine on your [local system using VirtualBox](get-started.md)
|
||||
- Install multiple machines [on your cloud provider](get-started-cloud.md)
|
||||
- [Digital Ocean Example](examples/ocean.md)
|
||||
- [AWS Example](examples/aws.md)
|
||||
- [Machine concepts and help](concepts.md)
|
||||
- [Migrate from Boot2Docker to Docker Machine](migrate-to-machine.md)
|
||||
- [Docker Machine driver reference](drivers/index.md)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ description = "Migrate from Boot2Docker to Docker Machine"
|
|||
keywords = ["machine, commands, boot2docker, migrate, docker"]
|
||||
[menu.main]
|
||||
parent="workw_machine"
|
||||
weight=4
|
||||
weight=-30
|
||||
+++
|
||||
<![end-metadata]-->
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ When people say "Docker" they typically mean **Docker Engine**, the client-serve
|
|||
- [Install Docker Machine](install-machine.md)
|
||||
- Create and run a Docker host on your [local system using VirtualBox](get-started.md)
|
||||
- Provision multiple Docker hosts [on your cloud provider](get-started-cloud.md)
|
||||
- [Provision a Docker Swarm cluster with Docker Machine](https://docs.docker.com/swarm/machine-provisioning/provision-w-machine/)
|
||||
- [Provision a Docker Swarm cluster with Docker Machine](https://docs.docker.com/swarm/provision-with-machine/)
|
||||
- [Understand Machine concepts](concepts.md)
|
||||
- <a href="https://docs.docker.com/machine/drivers/" target="_blank">Docker Machine driver reference</a>
|
||||
- <a href="https://docs.docker.com/machine/reference/" target="_blank">Docker Machine subcommand reference</a>
|
||||
- [Docker Machine driver reference](drivers/index.md)
|
||||
- [Docker Machine subcommand reference](reference/index.md)
|
||||
- [Migrate from Boot2Docker to Docker Machine](migrate-to-machine.md)
|
||||
|
|
|
|||
Loading…
Reference in New Issue