Run Docker images on SmartOS

This feature is available on the SkyLime SmartOS Version because we merged the changes from an existing issue into our branch to support the Docker Registry Version 2. This has been done because most of the existing Docker images only using version 2, which result in less usable images if you only support version 1. With this change no docker version 1 is supported any more, which is the biggest drawback if you've already version 1 images.

Usage

Configure imgadm to add docker hub sources:

$ imgadm sources --add-docker-hub

imgadm avail doesn't work against the Hub, so you'll have to search the Hub manually. But you could import images simple via the imgadm import command:

$ imgadm import busybox

Show installed docker images:

$ imgadm list --docker

UUID                                  REPOSITORY                             TAG  IMAGE_ID      CREATED
6357e9ab-0e79-5a0d-697b-b528d925026a  konradkleine/docker-registry-frontend  -    sha256:9976b  2017-10-11T23:50:25Z
5de66518-05f1-1ca2-34ee-6c8750a7a4bb  busybox                                -    sha256:0ffad  2017-11-03T22:39:17Z
1a99421d-7df8-23ec-1758-0b46b730aa1f  registry                               -    sha256:f792f  2017-12-01T22:15:41Z

Configure personal docker registry

Import the official image for the docker registry:

$ imgadm import registry

Install and activate docker registry with the vmadm command. For that store the following file on your SmartOS machine for example in /opt/docker-registry.json:

{
  "alias": "docker-registry",
  "hostname": "docker-registry.dev.example.com",
  "image_uuid": "1a99421d-7df8-23ec-1758-0b46b730aa1f",
  "nics": [
    {
      "nic_tag": "admin",
      "primary": true,
      "ips": [ "172.22.175.100/25" ],
      "gateways": [ "172.22.175.1" ]
    }
  ],
  "brand": "lx",
  "docker": "true",
  "kernel_version": "3.13.0",
  "max_physical_memory": 1024,
  "maintain_resolvers": true,
  "resolvers": [
    "8.8.8.8"
  ],
  "quota": 10,
  "internal_metadata": {
    "docker:cmd": "[\"/bin/sh\", \"/entrypoint.sh\", \"/etc/docker/registry/config.yml\"]"
  }
}

Please modify the ips, gateways and resolvers field in the JSON manifest.

The docker:cmd is based on the Dockerfile from the repository. The image_uuid need to be set to the latest version you've downloaded via imgadm. If you need to verify it run:

$ imgadm list --docker

Create and run the container:

$ vmadm create -f /opt/docker-registry.json

At the moment the configuration file described in the docker container show us that it will listen on port 5000.

Provide web interface for personal docker registry

This could be easily done with an image provided on Docker Hub.

$ imgadm import konradkleine/docker-registry-frontend:v2

Save the following manifest which describe the setup of the zone, for example in /opt/registry-web.json:

{
  "alias": "docker-registry-web",
  "hostname": "docker-registry-web.dev.example.com",
  "image_uuid": "6357e9ab-0e79-5a0d-697b-b528d925026a",
  "nics": [
    {
      "nic_tag": "admin",
      "primary": true,
      "ips": [ "172.22.175.101/25" ],
      "gateways": [ "172.22.175.1" ]
    }
  ],
  "brand": "lx",
  "docker": "true",
  "kernel_version": "3.13.0",
  "max_physical_memory": 1024,
  "maintain_resolvers": true,
  "resolvers": [
    "8.8.8.8"
  ],
  "quota": 10,
  "internal_metadata": {
    "docker:cmd": "[\"/root/start-apache.sh\"]",
    "docker:tty": true,
    "docker:attach_stdin": true,
    "docker:attach_stdout": true,
    "docker:attach_stderr": true,
    "docker:open_stdin": true,
    "docker:env": "[ \"ENV_DOCKER_REGISTRY_HOST=172.22.175.100\",\"ENV_DOCKER_REGISTRY_PORT=5000\"]",
    "docker:noipmgmtd": true
  }
}

You should be able to access the web service via http://172.22.175.101, or whatever IP you're using.

Docker Registry Frontend on SmartOS

Tipps

Logfiles for docker images are stored in the zone so you need to look there:

$ cat /zones/${UUID}/logs/stdio.log

You may like to login with a shell for some debugging:

$ zlogin -i ${UUID} /native/usr/vm/sbin/dockerexec /bin/sh

Posted

February 11, 2018, 12:46 pm

Tags

, , , , ,

More

Permalink

Comments

Send your comment by mail.