基本的には Install docker on FreeBSD に沿って勧めていくが若干修正がある。
% setenv MACHINE_STORAGE_PATH /tmp/docker
% docker-machine create -d virtualbox default
Creating CA: /tmp/docker/certs/ca.pem
Creating client certificate: /tmp/docker/certs/cert.pem
Running pre-create checks...
(default) Image cache directory does not exist, creating it at /tmp/docker/cache...
(default) No default Boot2Docker ISO found locally, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v19.03.12
(default) Downloading /tmp/docker/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v19.03.12/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying /tmp/docker/cache/boot2docker.iso to /tmp/docker/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet1"
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
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 your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
これで、default と名付けられた docker-machine が起動した。
docker-machine に env と言うコマンドがあり、設定を教えてくれる。bash だと、そのまま eval で実行して使える。
% docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/tmp/docker/machines/default"
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell:
# eval $(docker-machine env default)
tcsh なので、setenv を手動で。
% docker-machine env default
% setenv DOCKER_TLS_VERIFY "1"
% setenv DOCKER_HOST "tcp://192.168.99.100:2376"
% setenv DOCKER_CERT_PATH "/tmp/docker/machines/default"
% setenv DOCKER_MACHINE_NAME "default"
docker が使えるようになったので、あとは良く見る nginx で実験。
% docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
461246efe0a7: Pull complete
060bfa6be22e: Pull complete
b34d5ba6fa9e: Pull complete
8128ac56c745: Pull complete
44d36245a8c9: Pull complete
ebcc2cc821e6: Pull complete
Digest: sha256:1761fb5661e4d77e107427d8012ad3a5955007d997e0f4a3d41acc9ff20467c7
Status: Downloaded newer image for nginx:latest
% docker run --name nginx00 -d -p 8080:80 nginx:latest
f620dc5200389729a6de839b0a659cb95dc93ace24fc7d5c23a2ee278fdc7228
% docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f620dc520038 nginx:latest "/docker-entrypoint.〓〓" 3 minutes ago Up About a minute 0.0.0.0:8080->80/tcp nginx00
docker pull
でダウンロード、docker run
で起動し、docker ps
で確認した。
実は、localhost:8080 にアクセスしたが、エラーが出て何も表示されない。docker が動いていないのか、nginx が動いていないのかは、まだ調べていない。docker stop
等は動いているようだ。
セコメントをする