In my previous post I talked about how to build some Docker containers to run a deep learning-focused1 JupyterHub instance.
It’s nice for several reasons if the JupyterHub server brings itself up when the system starts. Here’s how to do that—an adaptation of this Stack Overflow post.
Create a file at /etc/systemd/system/docker-jupyterhub.service
and put the following text into the file.
[Unit]
Description=JupyterHub container
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/local/bin/docker-compose start -f /path/to/GPU-Jupyterhub/docker-compose.yml --project-directory /path/to/GPU-Jupyterhub/
ExecStop=/usr/local/bin/docker-compose stop -f /path/to/GPU-Jupyterhub/docker-compose.yml --project-directory /path/to/GPU-Jupyterhub/
[Install]
WantedBy=default.target
Once that file has been created, issue the following command:
sudo systemctl enable docker-jupyterhub.service
Now the JupyterHub server should start when the host computer boots and you won’t have to login to start it manually.
It was a little tricky to find that --project-directory
flag, and turns out it’s important to put the start
and stop
before any other arguments.
¯\_(ツ)_/¯
- ugh [return]