Docker - (Virtual) Host (or Machine or Server)

> Virtualization - (Virtual Machine|Container) > Docker

1 - About

An host (or machine) is:

  • a virtual host that you can see running in your virtual machine provider (such as virtual box).
  • is managed through the docker-machine executable (creation, start, stop,…)

The host operating system is boot2docker.

Advertising

3 - Management

3.1 - Environment variable

3.1.1 - Windows DOS shell

docker-machine env
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:\Users\gerard\.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('"C:\DockerToolbox\docker-machine.exe" env') DO @%i

3.1.2 - Linux bash shell

docker-machine env --shell=bash
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\gerard\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\DockerToolbox\docker-machine.exe" env --shell=bash)

3.2 - List

docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL   SWARM   DOCKER   ERRORS
default            virtualbox   Timeout

where:

3.3 - Driver

The driver indicate the provider on which to create the machine (ie the virtual engine).

Example:

See the Full List

You can register an already existing docker host by passing the daemon url.

docker-machine create --driver none --url=tcp://50.134.234.20:2376 custombox
docker-machine ls
NAME        ACTIVE   DRIVER    STATE     URL
custombox   *        none      Running   tcp://50.134.234.20:2376
Advertising

3.4 - Name

The environment variable DOCKER_MACHINE_NAME has the name of the host machine.

By default, you may find Moby because docker-compose comes from the Moby Project. This is the name that we will find in the host file (/etc/host) in the docker-compose service.

How to find your host name:

  • The DOCKER_MACHINE_NAME env variable
$ echo $DOCKER_MACHINE_NAME
default
  • Otherwise you see it in the NAME column when you list your hosts. See list

3.5 - IP

Three ways dependent of your configuration

  • Docker Host as Nat host on Windows
    • at the command line
netsh interface ip show addresses "vEthernet (DockerNAT)"
  • Windows graphically

docker-machine ip default
192.168.99.100

The DOCKER_HOST environment variable contains also the IP adress of the host

This IP is assigned by the docker-machine create subcommand.

Advertising

3.6 - Info !

docker info                                                                                            
Containers: 35                                                                                           
 Running: 1                                                                                              
 Paused: 0                                                                                               
 Stopped: 34                                                                                             
Images: 45                                                                                               
Server Version: 1.12.3                                                                                   
Storage Driver: aufs                                                                                     
 Root Dir: /mnt/sda1/var/lib/docker/aufs                                                                 
 Backing Filesystem: extfs                                                                               
 Dirs: 186                                                                                               
 Dirperm1 Supported: true                                                                                
Logging Driver: json-file                                                                                
Cgroup Driver: cgroupfs                                                                                  
Plugins:                                                                                                 
 Volume: local                                                                                           
 Network: bridge host null overlay                                                                       
 Log:                                                                                                    
Swarm: inactive                                                                                          
Runtimes: runc                                                                                           
Default Runtime: runc                                                                                    
Init Binary:                                                                                             
containerd version:                                                                                      
runc version:                                                                                            
init version:                                                                                            
Security Options:                                                                                        
 seccomp                                                                                                 
Kernel Version: 4.4.27-boot2docker                                                                       
Operating System: Boot2Docker 1.12.3 (TCL 7.2); HEAD : 7fc7575 - Thu Oct 27 17:23:17 UTC 2016            
OSType: linux                                                                                            
Architecture: x86_64                                                                                     
CPUs: 2                                                                                                  
Total Memory: 7.79GiB                                                                                    
Name: default                                                                                            
ID: 6CCC:JOTU:XXK3:ZJV6:7QTA:Y5LZ:EUAM:D3VM:XTVA:NQOY:5M2Z:KSC5                                          
Docker Root Dir: /mnt/sda1/var/lib/docker                                                                
Debug Mode (client): false                                                                               
Debug Mode (server): true                                                                                
 File Descriptors: 23                                                                                    
 Goroutines: 41                                                                                          
 System Time: 2017-10-24T15:05:24.245401217Z                                                             
 EventsListeners: 0                                                                                      
Registry: https://index.docker.io/v1/                                                                    
Labels:                                                                                                  
 provider=virtualbox                                                                                     
Experimental: false                                                                                      
Insecure Registries:                                                                                     
 127.0.0.0/8                                                                                             
Live Restore Enabled: false                                                                              

where you can see:

3.7 - Disk Location

3.8 - Data Persistence

Changes outside of the /var/lib/docker and /var/lib/boot2docker directories will be lost after powering down or restarting the host.

More ? See local customisation with persistent partition