About
A host in docker can be:
- a machine where docker server run
- or a network
This page is about the machine, to see the network, see the page Docker - Host Network.
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.
Articles Related
Management
Environment variable
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
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)
List
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default virtualbox Timeout
where:
Driver
The driver indicate the provider on which to create the machine (ie the virtual engine).
Example:
- virtualbox
- Azure
- Google
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
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
IP
Three ways to find the IP dependent of your configuration
Name
On windows, you can use the name host.docker.internal to reach the host.
Nat
If you are using a NAT, to determine the Docker Windows host IP interface (By default, this is the interface named vEthernet (DockerNAT) on the IP 10.0.75.1)
- at the command line with netsh
netsh interface ip show addresses
# and to filter for one interface
netsh interface ip show addresses "vEthernet (DockerNAT)"
Configuration for interface "vEthernet (DockerNAT)"
DHCP enabled: No
IP Address: 10.0.75.1
Subnet Prefix: 10.0.75.0/24 (mask 255.255.255.0)
InterfaceMetric: 15
- Windows graphically
Docker Machine
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.
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:
- the number of images
- the number of containers
- the volume plugin
- the network plugin
Disk Location
Data Persistence
Changes outside of the /var/lib/docker and /var/lib/boot2docker directories will be lost after powering down or restarting the host.