0% found this document useful (0 votes)
66 views9 pages

Using Docker On Windows: What Are Machines?

Docker Machine can manage multiple virtual machines that run Docker engines. The default Docker Machine for Windows is a VirtualBox virtual machine with limited resources. It is recommended to delete and recreate the default machine with more memory and disk space for production uses. The steps show how to delete the existing default machine and recreate it with 50GB disk space, 8GB memory and 4 CPUs for better performance and compatibility. Environment variables are then configured to use the new default machine.

Uploaded by

Ramaling
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views9 pages

Using Docker On Windows: What Are Machines?

Docker Machine can manage multiple virtual machines that run Docker engines. The default Docker Machine for Windows is a VirtualBox virtual machine with limited resources. It is recommended to delete and recreate the default machine with more memory and disk space for production uses. The steps show how to delete the existing default machine and recreate it with 50GB disk space, 8GB memory and 4 CPUs for better performance and compatibility. Environment variables are then configured to use the new default machine.

Uploaded by

Ramaling
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Using Docker on Windows

Overview
When using Docker on Windows or OS X you may face some additional challenges that those on Linux won't. Since Docker only runs natively on
Linux you will have an additional layer between your OS (Windows or OS X) and the Docker engine. In most cases this will be a Virtual Box VM
but could also be an Amazon EC2 instance or other virtual machine. The topic is oriented to Windows (8+) environment and assumes you have
already completed the Docker Toolbox installation instructions. The commands and concepts explained here should also apply to OS X in the
same ways.

About Docker Machines


What are machines?
The default Docker machine
Re-creating the Default Machine
Updating the Default Docker Machine
Troubleshooting
Starting Docker
Common Command Reference

About Docker Machines

What are machines?


Using Docker on Windows or OS X requires a Linux virtual machine be available to run the docker engine and your containers. The most common
type of machine used for local development is a Virtual Box machine. This allows a light weight Linux based VM to be started to run the Docker
engine and your containers. The docker-machine command allows you to manage these different machines by listing, creating and removing
available machines. Although Virtual Box machines are the most common there are other drivers supported such as Amazon EC2 as well.
Although you can create as many machines as you want, your docker client which issues your commands to the docker engine will only be
pointing to one machine at a time.

Docker Machine can manage multiple target machines. Docker Client can be pointed to one machine at a time.
The default Docker machine
When you launch the Docker Quickstart Terminal the start script will automatically check for a machine called default and create it if it does not
exist. Once created this machine is started automatically for you. This machine is good enough for many standard use cases, but may not have
enough memory or hard drive space for enterprise applications such as Oracle SOA Suite and BPM. The default machine information can be
obtained with a docker info command in the terminal window. The machine has 20 GB of hard disk and 2gb of memory by default.

Because of the limited memory and disk space it is recommended that you delete and re-create the default docker machine with more
capacity. By re-creating the machine with the same name the Docker Quickstart Terminal will still start the machine automatically for
you and configure the environment automatically for the docker client.

It is also possible to update the existing machine as well, but this shouldn't be necessary.

Both methods are described below, although re-creating is the recommended option.

The Database image user password will expire soon after creating it. To connect to the database use sys as sysdba/oracle.

Re-creating the Default Machine


The steps below will delete and re-create the default machine with increased disk space and memory. The disk space is just a maximum capacity,
Virtual Box will only allocate space as it is actually needed. All of the commands below should be executed in the Docker Quickstart Terminal.

1. List the current Docker machines using the docker-machine ls command. The output below shows the standard or "default" machine
created by boot2docker.

$ docker-machine ls
NAME ACTIVE DRIVER STATE URL
SWARM ERRORS
default - virtualbox Running tcp://192.168.99.101:2376

2. Run the docker-machine rm default command to remove the default docker machine.

$ docker-machine rm default
(default) Stopping VM...
Successfully removed default

3. Run the following command to create a new Docker machine named "default" using the Oracle VirtualBox driver with 50 GB of hard disk
space, 8 GB of memory and 4 CPUs. This command will create and start the machine.
$ docker-machine create --virtualbox-disk-size 50000
--virtualbox-memory 8192 --virtualbox-cpu-count 4 -d virtualbox
default
Running pre-create checks...
Creating machine...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting VM...
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 with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect Docker to this machine, run: C:\Program
Files\Docker Toolbox\docker-machine.exe env default

4. List the Docker machines once again and you should see the new default machine in a Running state.

$ docker-machine ls
NAME ACTIVE DRIVER STATE URL
SWARM ERRORS
default - virtualbox Running tcp://192.168.99.103:2376

5. Each Docker machine will have it's own IP address assigned. With the new machine setup we need to setup the environment to use the
new IP. Run the docker-machine env default command. It will produce output like that shown below.

$ docker-machine env default


export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.104:2376"
export
DOCKER_CERT_PATH="C:\Users\ghughlett\.docker\machine\machines\defau
lt"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval "$(C:\Program Files\Docker Toolbox\docker-machine.exe env
default)"

6. The recommended eval command will configure all of the required environment variables for the docker client, although the spaces in the
path to docker-machine will cause problems. docker-machine should already be on your path so you can simply execute the following
command to setup your environment. You will not need to do this every time because the Docker Quickstart Terminal executes this for
6.

the default automatically when starting.

eval "$(docker-machine env default)"

7. You can now execute the docker info command as well as an export command to confirm your environment has been setup correctly.
You will see DOCKER_HOST and DOCKER_MACHINE_NAME set, the Total Memory on the machine is 8gb and there are now 4 CPUs.

$ export | grep DOCKER


declare -x
DOCKER_CERT_PATH="C:\\Users\\adesjard.ADESJARD-WIN7\\.docker\\machi
ne\\machines\\default"
declare -x DOCKER_HOST="tcp://192.168.99.100:2376"
declare -x DOCKER_MACHINE_NAME="default"
declare -x DOCKER_TLS_VERIFY="1"
declare -x DOCKER_TOOLBOX_INSTALL_PATH="C:\\Program Files\\Docker
Toolbox"

$ docker info
Containers: 0
Images: 0
Server Version: 1.9.1
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 0
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b -
Fri Nov 20 1
9:33:59 UTC 2015
CPUs: 4
Total Memory: 7.79 GiB
Name: default
ID: MKNO:PELR:IPVT:BH4C:4HUM:KKA3:VQPM:MUZB:FAIW:LQYU:VXDB:LIVB
Debug mode (server): true
File Descriptors: 11
Goroutines: 18
System Time: 2016-02-23T18:41:14.542267991Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
provider=virtualbox
Updating the Default Docker Machine
If you follow the steps below it is because you do not wish to create a new Docker machine but simply want to update the default Docker machine
created by the installation. This should only be done if you have already been working in the default machine and don't want to lose containers or
images you have there.

1. First, you need to locate where VBoxManage.exe is located on your Windows machine.
2. Open the Docker Quickstart Terminal and wait for the $ prompt.
3. Stop the default machine (docker-machine stop default) so that it can be modified

$ docker-machine stop default


(default) Stopping VM...

4. Run VBoxManage.exe by pasting the specific path into the Docker Terminal and adding an additional backslash to the path name to
escape the backlash character. Append "modifyvm default --memory 8192 --cpus 4" to the VBoxManage command as shown below to
increase the memory to 8gb and the CPUs to 4.

C:\\oracle\\virtualbox\\VBoxManage.exe modifyvm default --memory


8192

5. After running the memory alteration start the default machine (docker-machine start default) and run docker info command to verify
the change.
$ docker-machine start default
(default) Starting VM...
Started machines may have new IP addresses. You may need to re-run
the `docker-machine env` command.

$ docker info
Containers: 1
Images: 99
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 101
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b -
Fri Nov 20 19:33:59 UTC 2015
CPUs: 4
Total Memory: 5.821 GiB
Name: default
ID: GWF6:E45E:F4TZ:74QW:MLFH:U557:D7SQ:P7O3:ZJKR:667G:UYX5:L6EF
Debug mode (server): true
File Descriptors: 17
Goroutines: 29
System Time: 2015-12-18T21:16:40.983712143Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
provider=virtualbox

Troubleshooting

Starting Docker
Running any docker command you may see the following error (e.g. docker ps).

$ docker ps
Get http://127.0.0.1:2375/v1.19/containers/json: dial tcp
127.0.0.1:2375: ConnectEx tcp: No connection could be made because the
target machine actively refused it.. Are you trying to connect to a
TLS-enabled daemon without TLS?
This means that the docker client is not able to communicate with your docker machine. When starting the Docker Quickstart Terminal your
environment is automatically configured for the default machine and the IP for that machine is printed when the terminal is first opened.

## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/

docker is configured to use the default machine with IP 192.168.99.101


For help getting started, check out the docs at https://docs.docker.com

If you are using the default docker machine still you should verify the machine is running properly in Virtual Box.

If you are not using a machine called default then you will need to start your machine and setup your own environment using the docker-machine
commands below each time you open the Docker Quickstart Terminal.

$ docker-machine start avio-machine


(avio-machine) Starting VM...
Started machines may have new IP addresses. You may need to re-run the
`docker-machine env` command.

$ eval "$(docker-machine env avio-machine)"

You can also modify the script C:\Program Files\Docker Toolbox\start.sh and update the line VM=default to have the Quickstart Terminal start
and configure your environment for a different machine than default. In this example it will now start the avio-machine VM each time the terminal
is opened.

#!/bin/bash

trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong...
Press any key to continue..."' EXIT

VM=avio-machine
DOCKER_MACHINE=./docker-machine.exe

Common Command Reference


List Machines

docker-machine ls

Create a Machine

docker-machine create --virtualbox-disk-size "50000" --virtualbox-memory


"8192" -d virtualbox machine-name

Stop and Start Machines

docker-machine start machine-name


docker-machine stop machine-name
docker-machine restart machine-name

Set Docker Client Environment

docker-machine env machine-name

eval "$(docker-machine env machine-name)"

Current Machine Information

docker-machine active
docker-machine ip machine-name

Connect to a Machine

docker-machine ssh machine-name

Summary
Despite some of the additional work needed to accommodate the Docker on Windows, using it is still advantageous as the images are built,
tested and up to date with patches.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy