Skip to content

Instantly share code, notes, and snippets.

@furushchev
Last active December 5, 2017 03:12
Show Gist options
  • Save furushchev/fd989def4f167b0aadf4608c3dcbc242 to your computer and use it in GitHub Desktop.
Save furushchev/fd989def4f167b0aadf4608c3dcbc242 to your computer and use it in GitHub Desktop.
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --default-runtime=nvidia -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target

Environment

  • Ubuntu 16.04
  • NVIDIA CUDA 9.0 Installed
  • Docker 17.09.0-ce, build afdb6d4 Installed

Install NVIDIA Docker

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

Configure docker.service

Change docker.service

- ExecStart=/usr/bin/dockerd -H fd://
+ ExecStart=/usr/bin/dockerd --default-runtime=nvidia -H fd://

Register Portainer Service

Create portainer.service

[
{
"type": "container",
"title": "ROS Lunar",
"description": "ROS pre-installed container",
"logo": "https://gist.githubusercontent.com/furushchev/fd989def4f167b0aadf4608c3dcbc242/raw/e3420918c6a2f400498fa23ae9cbc46058b5ab59/ros.png",
"image": "osrf/ros:lunar-desktop-full-xenial",
"interactive": true,
"command": "/bin/bash",
"platform": "linux",
"categories": ["ROS", "Ubuntu"]
},
{
"type": "container",
"title": "ROS Kinetic",
"description": "ROS pre-installed container",
"logo": "https://gist.githubusercontent.com/furushchev/fd989def4f167b0aadf4608c3dcbc242/raw/e3420918c6a2f400498fa23ae9cbc46058b5ab59/ros.png",
"image": "osrf/ros:kinetic-desktop-full-xenial",
"interactive": true,
"command": "/bin/bash",
"platform": "linux",
"categories": ["ROS", "Ubuntu"]
},
{
"type": "container",
"title": "ROS Jade",
"description": "ROS pre-installed container",
"logo": "https://gist.githubusercontent.com/furushchev/fd989def4f167b0aadf4608c3dcbc242/raw/e3420918c6a2f400498fa23ae9cbc46058b5ab59/ros.png",
"image": "osrf/ros:jade-desktop-full-trusty",
"interactive": true,
"command": "/bin/bash",
"platform": "linux",
"categories": ["ROS", "Ubuntu"]
},
{
"type": "container",
"title": "ROS Indigo",
"description": "ROS pre-installed container",
"logo": "https://gist.githubusercontent.com/furushchev/fd989def4f167b0aadf4608c3dcbc242/raw/e3420918c6a2f400498fa23ae9cbc46058b5ab59/ros.png",
"image": "osrf/ros:indigo-desktop-full-trusty",
"interactive": true,
"command": "/bin/bash",
"platform": "linux",
"categories": ["ROS", "Ubuntu"]
},
{
"type": "container",
"title": "ROS Kinetic Jessie",
"description": "ROS pre-installed container",
"logo": "https://gist.githubusercontent.com/furushchev/fd989def4f167b0aadf4608c3dcbc242/raw/e3420918c6a2f400498fa23ae9cbc46058b5ab59/ros.png",
"image": "osrf/ros:kinetic-desktop-full-jessie",
"interactive": true,
"command": "/bin/bash",
"platform": "linux",
"categories": ["ROS", "Debian"]
}
]
# /etc/systemd/system/multi-user.target.wants/portainer.service
[Unit]
Description=Protainer Docker Container Manager
After=docker.service
Requires=docker.service
Wants=nvidia-docker.service
[Service]
Group=docker
Type=simple
TimeoutStartSec=0
Restart=on-failure
RestartSec=10
ExecStartPre=-/usr/bin/docker kill portainer
ExecStartPre=-/usr/bin/docker rm portainer
ExecStartPre=-/usr/bin/docker volume create portainer_data
ExecStartPre=/usr/bin/docker pull portainer/portainer
ExecStart=/usr/bin/docker run --rm --name portainer -p 80:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
ExecStop=/usr/bin/docker stop portainer
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment