How To Run Docker in Hyper.sh

Hyper.sh

How to run Docker in Hyper.sh

Lately we have received a lot of requests asking how to run Docker in Hyper.sh. This post shows you a few ways to setup a Docker daemon, and launch Docker containers inside of a Hyper container.


Ubuntu 16.04

$ ID=`hyper run -d ubuntu:16.04`                    # launch an Ubuntu container
$ hyper exec -it ${ID} /bin/bash                    # get shell access
# apt-get update                                    
# apt-get install docker.io cgroup-lite screen -y   # install dependencies
# cgroups-mount                                     # mount cgroup
# screen -dmS docker_daemon dockerd -D              # Do NOT use `service docker start`
# docker info                                       # if this works, you are all set

CentOS 7.0

$ ID=`hyper run -d centos:7`
$ hyper exec -it ${ID} /bin/bash
# yum install libcgroup e2fsprogs iptables screen docker -y
# mkdir -p /cgroup/memory && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,memory cgroup /cgroup/memory
# mkdir -p /cgroup/cpuset && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,cpuset cgroup /cgroup/cpuset
# mkdir -p /cgroup/cpu,cpuacct && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,cpu,cpuacct cgroup /cgroup/cpu,cpuacct
# mkdir -p /cgroup/net_cls,net_prio && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,net_cls,net_prio cgroup /cgroup/net_cls,net_prio
# mkdir -p /cgroup/blkio && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,blkio cgroup /cgroup/blkio
# mkdir -p /cgroup/freezer && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,freezer cgroup /cgroup/freezer
# mkdir -p /cgroup/perf_event && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,perf_event cgroup /cgroup/perf_event
# mkdir -p /cgroup/devices && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,devices cgroup /cgroup/devices
# mkdir -p /cgroup/pids && mount -t cgroup -o rw,nosuid,nodev,noexec,relatime,pids cgroup /cgroup/pids
# screen -dmS docker_daemon /usr/bin/dockerd-current \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current
# docker info

Prebaked Docker Images!

Prefer to use something prebaked? Check out our repository on Docker hub: https://hub.docker.com/r/hyperhq/docker-in-hyper/

You can use the following tags: - hyperhq/docker-in-hyper:ubuntu-16.04 - hyperhq/docker-in-hyper:centos7 (latest)

Usage

$ hyper run -d -P hyperhq/docker-in-hyper
8dcb2ab017eb4603ae1d9a92ffc68e5cf0edec63e780f9180228eabfce47e028
$ hyper ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                                      NAMES                   PUBLIC IP
8dcb2ab017eb        hyperhq/docker-in-hyper   "/entrypoint.sh /bin/"   1 minutes ago       Up 1 minutes        0.0.0.0:2375->2375/tcp                     clever-shirley
$ hyper exec -it 8dcb2ab01 /bin/bash
[root@8dcb2ab017eb /]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Questions?

Feel free to drop us an email contact@hyper.sh, or use the forum, Twitter or in the console support window!