0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

supervisordを使用してコンテナ内でsshdをroot権限、JupyterLabをユーザー権限で動作させるためのDockerfileなど

Last updated at Posted at 2020-12-20

はじめに

記事の内容の概要を書く

目次

  • 項目1
  • 項目2
  • 項目3

1. 項目1

Dockerfile

Dockerfile
FROM ubuntu:20.10

## define these environment variables for installing git silently
ENV TZ=Asia/Tokyo DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y \
    git \
    imagemagick \
    libsm6 \
    libxext6 \
    libxrender-dev \
    libglib2.0-0 \
    openssh-server \
    sudo \
    supervisor \
    wget \
    vim


## customized bellow

ARG USER_ID
ARG USER_NAME

COPY supervisord.conf /etc/supervisor/conf.d/
RUN sed -i s/USERNAME/$USER_NAME/g /etc/supervisor/conf.d/supervisord.conf && \
    sed -i 's/#X11UseLocalhost yes/X11UseLocalhost no/' /etc/ssh/sshd_config && \
    mkdir -p /var/run/sshd /var/log/supervisor && \
    useradd -m -u $USER_ID -s /bin/bash $USER_NAME

# install miniconda ${USER_NAME} locally

# download miniconda package and install miniconda

# set path
ENV PATH /home/$USER_NAME/miniconda3/bin:$PATH

WORKDIR /home/$USER_NAME

USER ${USER_NAME}

# download & install Miniconda3-py38_4.9.2-Linux-x86_64.sh (2020/11/23)
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.9.2-Linux-x86_64.sh && \
    sh ./Miniconda3-py38_4.9.2-Linux-x86_64.sh -b -p /home/$USER_NAME/miniconda3 && \
    rm -f ./Miniconda3-py38_4.9.2-Linux-x86_64.sh && \
    echo "export PATH=/home/$USER_NAME/miniconda3/bin:${PATH}" >> /home/$USER_NAME/.bashrc && \
    conda update -n base -c defaults conda -y && \
    conda install numpy scipy pandas seaborn matplotlib jupyter jupyterlab pip -y && \
    conda install flake8 lightgbm -y && \
    conda install nodejs -y && \
    conda install jupytext xgboost optuna -c conda-forge -y && \
    jupyter lab build && \
    pip install --upgrade pip && \
    pip install opencv-python && \
    pip install nibabel \
    pip install japanize-matplotlib

WORKDIR /

USER root

CMD ["/usr/bin/supervisord"]

supervisord.conf

supervisord.conf
[supervisord]
nodaemon=true

[program:sshd]
command=/usr/sbin/sshd -D

[program:jupyterlab]
command=/bin/bash -c "export PATH=/home/USERNAME/miniconda3/bin/:${PATH}; /home/USERNAME/miniconda3/bin/jupyter lab --ip=0.0.0.0 --allow-root --LabApp.token='' "
user=USERNAME
environment=HOME=/home/USERNAME, USER=USERNAME

docker-compose.yml

docker-compose.yml
version: '3'

services:
  base:
    build:
      context: .
      args:
        USER_ID: ${USER_ID}
        USER_NAME: ${USER}
    image: ${USER}/myimage
    ports:
      - '2022:22'
      - '8888:8888'
    volumes:
      - '~/.ssh:${HOME}/.ssh'
      - '~/src:${HOME}/src'

2.項目2

3.項目3

  • あれや
  • これや
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?