@@ -19,6 +19,7 @@ var client = http.Client{}
|
||||
// StartContainer Start container using REST api Implementation
|
||||
// From the selected server IP address
|
||||
// TODO: Test cases for this function
|
||||
//Calls URL ex: http://0.0.0.0:8088/startcontainer?ports=0&GPU=false&ContainerName=docker-ubuntu-sshd
|
||||
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string) (*docker.DockerVM ,error) {
|
||||
// Passes URL with number of TCP ports to allocated and to give GPU access to the docker container
|
||||
URL := "http://" + IP + ":" + serverPort + "/startcontainer?ports=" + fmt.Sprint(NumPorts) + "&GPU=" + strconv.FormatBool(GPU) + "&ContainerName=" + ContainerName
|
||||
|
||||
41
server/docker/containers/cpuhorovod/Dockerfile
Normal file
41
server/docker/containers/cpuhorovod/Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
from horovod/horovod-cpu
|
||||
# Switch to root user to install additional software
|
||||
USER 0
|
||||
|
||||
|
||||
# Make sure we don't get notifications we can't answer during building.
|
||||
env DEBIAN_FRONTEND noninteractive
|
||||
|
||||
|
||||
# Prepare scripts and configs
|
||||
add ./scripts/start /start
|
||||
|
||||
|
||||
# Set root password
|
||||
run echo 'root:password' >> /root/passwdfile
|
||||
|
||||
|
||||
# Create user and it's password
|
||||
run useradd -m -G sudo master && \
|
||||
echo 'master:password' >> /root/passwdfile
|
||||
|
||||
|
||||
# Apply root password
|
||||
run chpasswd -c SHA512 < /root/passwdfile && \
|
||||
rm /root/passwdfile
|
||||
|
||||
|
||||
# Port 22 is used for ssh
|
||||
expose 22
|
||||
|
||||
|
||||
# Assign /data as static volume.
|
||||
volume ["/data"]
|
||||
|
||||
|
||||
# Fix all permissions
|
||||
run chmod +x /start
|
||||
|
||||
|
||||
# Starting sshd
|
||||
cmd ["/start"]
|
||||
1
server/docker/containers/cpuhorovod/description.txt
Normal file
1
server/docker/containers/cpuhorovod/description.txt
Normal file
@@ -0,0 +1 @@
|
||||
Running official horovod dockerfile cpu version
|
||||
11
server/docker/containers/cpuhorovod/scripts/start
Normal file
11
server/docker/containers/cpuhorovod/scripts/start
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# -----------------------------------------------------------------------------
|
||||
# docker-ubuntu-sshd /start script
|
||||
#
|
||||
# Authors: Art567
|
||||
# Updated: Sep 20th, 2015
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Run OpenSSH server in daemon mode
|
||||
/usr/sbin/sshd -D
|
||||
@@ -93,14 +93,18 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
}
|
||||
RespDocker.ImagePath = config.DefaultDockerFile
|
||||
|
||||
if ContainerName != "" {
|
||||
// We are checking if the container name is not nil and not equal to the default one used
|
||||
// which is docker-ubuntu-sshd
|
||||
if ContainerName != "" && ContainerName != "docker-ubuntu-sshd" {
|
||||
Containers, err := ViewAllContainers()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
}
|
||||
|
||||
for _, dockerContainer := range Containers.DockerContainer {
|
||||
if dockerContainer.ContainerName == ContainerName {
|
||||
RespDocker.ImagePath = config.DockerContainers + ContainerName + "/"
|
||||
RespDocker.TagName = ContainerName
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -310,7 +314,6 @@ func ViewAllContainers() (*DockerContainers, error){
|
||||
|
||||
for _, f := range folders {
|
||||
if f.IsDir() {
|
||||
fmt.Print(f.Name())
|
||||
//Declare variable DockerContainer of type struct
|
||||
var Container DockerContainer
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDocker(t *testing.T) {
|
||||
//TODO overwrite with custom docker paths
|
||||
resp,err := BuildRunContainer(2,"true","")
|
||||
// Testing by providing default container name
|
||||
_,err := BuildRunContainer(2,"false","docker-ubuntu-sshd")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
// Testing if no container name is provided if default is used
|
||||
_,err = BuildRunContainer(2,"false","")
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
fmt.Print(resp.VNCPort)
|
||||
}
|
||||
|
||||
func TestViewAllContainers(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user