aboutsummaryrefslogtreecommitdiffstats
path: root/docker/docker_remote_api/enable_remote_api.sh
diff options
context:
space:
mode:
authorhelenyao <yaohelan@huawei.com>2016-11-10 21:08:02 -0500
committerhelenyao <yaohelan@huawei.com>2016-11-10 22:24:24 -0500
commiteb018c7aeb8445db36ed18835803c61f730945cd (patch)
treeec074e2bafcd9902f904413646066521abd579c2 /docker/docker_remote_api/enable_remote_api.sh
parentb8e03925b445f5c39c090a40bd8e7d6bbc0c8910 (diff)
Add script to enable Docker Remote API by updating Docker Daemon configuration
JIRA: FUNCTEST-520 This script will be used once the docker slicing decide is made. Currently, the script has been tested on Ubuntu 14.04 and 16.04 and CentOS 7.2. A document about how to enable TLS is included when taking security into account. Change-Id: I4e5e58ed68d75528bf8497aba118f9dbb51dddad Signed-off-by: helenyao <yaohelan@huawei.com>
Diffstat (limited to 'docker/docker_remote_api/enable_remote_api.sh')
-rw-r--r--docker/docker_remote_api/enable_remote_api.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/docker/docker_remote_api/enable_remote_api.sh b/docker/docker_remote_api/enable_remote_api.sh
new file mode 100644
index 00000000..6867eedd
--- /dev/null
+++ b/docker/docker_remote_api/enable_remote_api.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+
+# ******************************
+# Script to update the docker host configuration
+# to enable Docker Remote API
+# ******************************
+
+if [ -f /etc/lsb-release ]; then
+ #tested on ubuntu 14.04 and 16.04
+ if grep -q "#DOCKER_OPTS=" "/etc/default/docker"; then
+ cp /etc/default/docker /etc/default/docker.bak
+ sed -i 's/^#DOCKER_OPTS.*$/DOCKER_OPTS=\"-H unix:\/\/\/var\/run\/docker.sock -H tcp:\/\/0.0.0.0:2375\"/g' /etc/default/docker
+ else
+ echo DOCKER_OPTS=\"-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375\" >> /etc/default/docker
+ fi
+ service docker restart
+ #docker start $(docker ps -aq)
+elif [ -f /etc/system-release ]; then
+ #tested on centos 7.2
+ if grep -q "ExecStart=\/usr\/bin\/docker-current daemon" "/lib/systemd/system/docker.service"; then
+ cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service.bak
+ sed -i 's/^ExecStart=.*$/ExecStart=\/usr\/bin\/docker daemon -H tcp:\/\/0.0.0.0:2375 -H unix:\/\/\/var\/run\/docker.sock \\/g' /lib/systemd/system/docker.service
+ systemctl daemon-reload
+ systemctl restart docker
+ else
+ echo "to be implemented"
+ fi
+else
+ echo "OS is not supported"
+fi
+
+# Issue Note for Ubuntu
+# 1. If the configuration of the file /etc/default/docker does not take effect after restarting docker service,
+# you may try to modify /lib/systemd/system/docker.service
+# commands:
+# cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service.bak
+# sed -i '/^ExecStart/i\EnvironmentFile=-/etc/default/docker' /lib/systemd/system/docker.service
+# sed -i '/ExecStart=\/usr\/bin\/dockerd/{;s/$/ \$DOCKER_OPTS/}' /lib/systemd/system/docker.service
+# systemctl daemon-reload
+# service docker restart
+# 2. Systemd is a system and session manager for Linux, where systemctl is one tool for systemd to view and control systemd.
+# If the file /lib/systemd/system/docker.service is modified, systemd has to be reloaded to scan new or changed units.
+# 1) systemd and related packages are available on the PPA. To use the PPA, first add it to your software sources list as follows.
+# add-apt-repository ppa:pitti/systemd
+# apt-get update
+# 2) system can be installed from the PPS as follows.
+# apt-get install systemd libpam-systemd systemd-ui
+
+
+