DC/OS Vagrant can optionally be deployed with a private Docker registry running on the bootstrap (boot
) machine. This functionality must be enabled at deploy time.
The following steps demonstrate how to enable and use the private Docker registry to deploy Nginx:
-
Enable the private registry:
$ export DCOS_PRIVATE_REGISTRY=true
-
SSH into one of the machines:
$ vagrant ssh boot
-
Download nginx from Docker Hub:
$ docker pull nginx
-
Retag the nginx image:
$ docker tag $(docker images | grep -m 1 ^nginx.*latest | awk -v N=3 '{print $N}') boot.dcos:5000/nginx
-
Upload nginx to the private registry:
$ docker push boot.dcos:5000/nginx
-
Install the DC/OS CLI:
The following instructions are tailored to the CentOS base image, dcos-vagrant, and dcos-cli 0.4.4. For general reference, see Installing the DC/OS CLI
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && sudo python get-pip.py && sudo pip install virtualenv && mkdir dcos && cd dcos && curl -O https://downloads.dcos.io/dcos-cli/install.sh && bash ./install.sh . https://m1.dcos && cd .. && source ./dcos/bin/env-setup
Enter
yes
orno
when prompted withModify your bash profile to add DCOS to your PATH? [yes/no]
. -
Prepare a DC/OS service definition:
$ tee nginx-marathon.json <<-'EOF' { "id": "/nginx", "instances": 1, "cpus": 0.5, "mem": 128, "container": { "type": "DOCKER", "docker": { "image": "boot.dcos:5000/nginx", "network": "HOST" } }, "healthChecks": [ { "protocol": "COMMAND", "command": { "value": "service nginx status | grep -q 'nginx is running.'"}, "gracePeriodSeconds": 300, "intervalSeconds": 60, "timeoutSeconds": 20, "maxConsecutiveFailures": 3 } ], "labels": { "DCOS_SERVICE_NAME": "nginx", "DCOS_SERVICE_SCHEME": "http", "DCOS_SERVICE_PORT_INDEX": "0" } } EOF ```
-
Create a DC/OS service:
$ dcos marathon app add nginx-marathon.json
If auth is enabled, authenticate as instructed by the CLI.
-
Test the nginx endpoint
$ curl nginx.marathon.mesos <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>